List:Internals« Previous MessageNext Message »
From:jan.lindstrom Date:July 20 2004 1:15pm
Subject:bk commit into 4.1 tree (jan:1.1969)
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jan. When jan does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1969 04/07/20 14:15:38 jan@stripped +8 -0
  Added innodb_locks_unsafe_for_binlog option. This option turns off Innodb 
    next-key locking. Using this option the locks InnoDB sets on index 
    records do not affect the ``gap'' before that index record. Thus, this option
    allows phantom problem.

  BitKeeper/etc/logging_ok
    1.323 04/07/20 14:11:07 jan@stripped +1 -0
    Logging to logging@stripped accepted

  sql/set_var.cc
    1.127 04/07/20 14:10:29 jan@stripped +1 -0
    Added innodb_locks_unsafe_for_binlog and innobase_locks_unsafe_for_binlog for
    innodb_locks_unsafe_for_binlog option.

  sql/mysqld.cc
    1.482 04/07/20 14:10:29 jan@stripped +5 -0
    Added OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG, innobase_locks_unsafe_for_binlog for
    innodb_locks_unsafe_for_binlog option.

  sql/ha_innodb.h
    1.69 04/07/20 14:10:29 jan@stripped +1 -1
    Added innobase_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option.
    

  sql/ha_innodb.cc
    1.140 04/07/20 14:10:28 jan@stripped +2 -0
    Added innobase_locks_unsafe_for_binlog and srv_locks_unsafe_for_binlog for 
    innodb_locks_unsafe_for_binlog option.

  innobase/srv/srv0srv.c
    1.64 04/07/20 14:10:28 jan@stripped +4 -0
    Added srv_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option.
    

  innobase/row/row0sel.c
    1.52 04/07/20 14:10:28 jan@stripped +76 -7
    If innodb_locks_unsafe_for_binlog option is used, we lock only the record, i.e. 
    next-key locking is not used. Therefore, setting lock to the index record
    do not affect the ``gap'' before that index record. Thus, this option
    allows phantom problem, because concurrent insert operations are allowed inside 
    the select range.

  innobase/include/srv0srv.h
    1.34 04/07/20 14:10:28 jan@stripped +1 -0
    Added srv_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jan
# Host:	hundin.mysql.fi
# Root:	/home/jan/mysql-4.1

--- 1.481/sql/mysqld.cc	Mon Jul 12 07:38:43 2004
+++ 1.482/sql/mysqld.cc	Tue Jul 20 14:10:29 2004
@@ -3880,6 +3880,7 @@
   OPT_INNODB_FLUSH_METHOD,
   OPT_INNODB_FAST_SHUTDOWN,
   OPT_INNODB_FILE_PER_TABLE, OPT_CRASH_BINLOG_INNODB,
+  OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG,
   OPT_SAFE_SHOW_DB, OPT_INNODB_SAFE_BINLOG,
   OPT_INNODB, OPT_ISAM, OPT_NDBCLUSTER, OPT_SKIP_SAFEMALLOC,
   OPT_TEMP_POOL, OPT_TX_ISOLATION,
@@ -4156,6 +4157,10 @@
    "Stores each InnoDB table to an .ibd file in the database dir.",
    (gptr*) &innobase_file_per_table,
    (gptr*) &innobase_file_per_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"innodb_locks_unsafe_for_binlog", OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG,
+   "Force Innodb not to use next-key locking. Instead use only row-level locking",
+   (gptr*) &innobase_locks_unsafe_for_binlog,
+   (gptr*) &innobase_locks_unsafe_for_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif /* End HAVE_INNOBASE_DB */
   {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new
connection",
    (gptr*) &opt_init_connect, (gptr*) &opt_init_connect, 0, GET_STR_ALLOC,

--- 1.322/BitKeeper/etc/logging_ok	Tue Jul  6 18:30:49 2004
+++ 1.323/BitKeeper/etc/logging_ok	Tue Jul 20 14:11:07 2004
@@ -61,6 +61,7 @@
 igor@stripped
 igor@stripped
 ingo@stripped
+jan@stripped
 jani@stripped
 jani@stripped
 jani@stripped

--- 1.33/innobase/include/srv0srv.h	Thu May 27 15:03:51 2004
+++ 1.34/innobase/include/srv0srv.h	Tue Jul 20 14:10:28 2004
@@ -42,6 +42,7 @@
 #endif /* UNIV_LOG_ARCHIVE */
 
 extern ibool	srv_file_per_table;
+extern ibool    srv_locks_unsafe_for_binlog;
 
 extern ulint	srv_n_data_files;
 extern char**	srv_data_file_names;

--- 1.51/innobase/row/row0sel.c	Thu May 27 15:03:51 2004
+++ 1.52/innobase/row/row0sel.c	Tue Jul 20 14:10:28 2004
@@ -631,10 +631,24 @@
 
 	if (!node->read_view) {
 		/* Try to place a lock on the index record */
-		
+        
+          /* If innodb_locks_unsafe_for_binlog option is used, 
+             we lock only the record, i.e. next-key locking is
+             not used.
+	  */
+	  if ( srv_locks_unsafe_for_binlog )
+	    {
+		err = lock_clust_rec_read_check_and_lock(0, clust_rec, 
+                        index,node->row_lock_mode, LOCK_REC_NOT_GAP, thr);
+	    }
+	  else
+	    {		
 		err = lock_clust_rec_read_check_and_lock(0, clust_rec, index,
 				node->row_lock_mode, LOCK_ORDINARY, thr);
-		if (err != DB_SUCCESS) {
+
+	    }
+
+	    if (err != DB_SUCCESS) {
 
 			return(err);
 		}
@@ -1184,9 +1198,23 @@
 		search result set, resulting in the phantom problem. */
 		
 		if (!consistent_read) {
+
+		  /* If innodb_locks_unsafe_for_binlog option is used,
+                     we lock only the record, i.e. next-key locking is
+                     not used.
+		  */
+
+                  if ( srv_locks_unsafe_for_binlog )
+		    {
+			err = sel_set_rec_lock(page_rec_get_next(rec), index,
+				node->row_lock_mode, LOCK_REC_NOT_GAP, thr);
+		    } 
+                    else
+		    {
 			err = sel_set_rec_lock(page_rec_get_next(rec), index,
 				node->row_lock_mode, LOCK_ORDINARY, thr);
-			if (err != DB_SUCCESS) {
+		    }
+		    if (err != DB_SUCCESS) {
 				/* Note that in this case we will store in pcur
 				the PREDECESSOR of the record we are waiting
 				the lock for */
@@ -1211,8 +1239,22 @@
 	if (!consistent_read) {
 		/* Try to place a lock on the index record */	
 
-		err = sel_set_rec_lock(rec, index, node->row_lock_mode,
+		  /* If innodb_locks_unsafe_for_binlog option is used,
+                     we lock only the record, i.e. next-key locking is
+                     not used.
+		  */
+
+                  if ( srv_locks_unsafe_for_binlog )
+		    {
+		        err = sel_set_rec_lock(rec, index, node->row_lock_mode,
+						LOCK_REC_NOT_GAP, thr);
+		    } 
+		  else
+		    {
+		        err = sel_set_rec_lock(rec, index, node->row_lock_mode,
 						LOCK_ORDINARY, thr);
+		    }
+
 		if (err != DB_SUCCESS) {
 
 			goto lock_wait_or_error;
@@ -3144,10 +3186,24 @@
 
 			/* Try to place a lock on the index record */	
 
-			err = sel_set_rec_lock(rec, index,
+                        /* If innodb_locks_unsafe_for_binlog option is used, 
+                           we lock only the record, i.e. next-key locking is
+                           not used.
+	                */
+	                if ( srv_locks_unsafe_for_binlog )
+	                {
+			    err = sel_set_rec_lock(rec, index,
+						prebuilt->select_lock_type,
+						LOCK_REC_NOT_GAP, thr);
+			}
+			else
+			{
+			    err = sel_set_rec_lock(rec, index,
 						prebuilt->select_lock_type,
 						LOCK_ORDINARY, thr);
-			if (err != DB_SUCCESS) {
+			}
+			
+                        if (err != DB_SUCCESS) {
 
 				goto lock_wait_or_error;
 			}
@@ -3300,9 +3356,22 @@
 						prebuilt->select_lock_type,
 						LOCK_REC_NOT_GAP, thr);
 		} else {
-			err = sel_set_rec_lock(rec, index,
+                        /* If innodb_locks_unsafe_for_binlog option is used, 
+                           we lock only the record, i.e. next-key locking is
+                           not used.
+	                */
+	                if ( srv_locks_unsafe_for_binlog )
+	                {
+			    err = sel_set_rec_lock(rec, index,
+						prebuilt->select_lock_type,
+						LOCK_REC_NOT_GAP, thr);
+			}
+			else
+			{
+			    err = sel_set_rec_lock(rec, index,
 						prebuilt->select_lock_type,
 						LOCK_ORDINARY, thr);
+			}
 		}
 		
 		if (err != DB_SUCCESS) {

--- 1.63/innobase/srv/srv0srv.c	Fri Jun 18 04:23:14 2004
+++ 1.64/innobase/srv/srv0srv.c	Tue Jul 20 14:10:28 2004
@@ -74,6 +74,10 @@
 					created by an user; data dictionary
 					tables are in the system tablespace
 					0 */
+ibool   srv_locks_unsafe_for_binlog = FALSE; /* Place locks to records only 
+                                                i.e. do not use next-key locking
+                                                except on duplicate key checking and
+                                                foreign key checking */
 ulint	srv_n_data_files = 0;
 char**	srv_data_file_names = NULL;
 ulint*	srv_data_file_sizes = NULL;	/* size in database pages */ 

--- 1.139/sql/ha_innodb.cc	Thu Jun 24 00:52:46 2004
+++ 1.140/sql/ha_innodb.cc	Tue Jul 20 14:10:28 2004
@@ -117,6 +117,7 @@
 my_bool	innobase_use_native_aio			= FALSE;
 my_bool	innobase_fast_shutdown			= TRUE;
 my_bool	innobase_file_per_table			= FALSE;
+my_bool innobase_locks_unsafe_for_binlog        = FALSE;
 
 static char *internal_innobase_data_file_path	= NULL;
 
@@ -908,6 +909,7 @@
 	srv_fast_shutdown = (ibool) innobase_fast_shutdown;
 
 	srv_file_per_table = (ibool) innobase_file_per_table;
+        srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
 
 	srv_max_n_open_files = (ulint) innobase_open_files;
 

--- 1.68/sql/ha_innodb.h	Thu Jul  8 15:45:21 2004
+++ 1.69/sql/ha_innodb.h	Tue Jul 20 14:10:29 2004
@@ -189,7 +189,7 @@
 /* The following variables have to be my_bool for SHOW VARIABLES to work */
 extern my_bool innobase_log_archive,
                innobase_use_native_aio, innobase_fast_shutdown,
-	       innobase_file_per_table;
+	       innobase_file_per_table, innobase_locks_unsafe_for_binlog;
 extern "C" {
 extern ulong srv_max_buf_pool_modified_pct;
 }

--- 1.126/sql/set_var.cc	Sat Jul 10 14:21:33 2004
+++ 1.127/sql/set_var.cc	Tue Jul 20 14:10:29 2004
@@ -673,6 +673,7 @@
   {"innodb_fast_shutdown", (char*) &innobase_fast_shutdown, SHOW_MY_BOOL},
   {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
   {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
+  {"innodb_locks_unsafe_for_binlog", (char*) &innobase_locks_unsafe_for_binlog,
SHOW_MY_BOOL},
   {"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit,
SHOW_INT},
   {"innodb_flush_method",    (char*) &innobase_unix_file_flush_method,
SHOW_CHAR_PTR},
   {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
Thread
bk commit into 4.1 tree (jan:1.1969)jan.lindstrom20 Jul