diff options
author | unknown <jan@hundin.mysql.fi> | 2004-07-20 14:15:38 +0300 |
---|---|---|
committer | unknown <jan@hundin.mysql.fi> | 2004-07-20 14:15:38 +0300 |
commit | 238b226f2626573021103872b85d54a79c5743ea (patch) | |
tree | 7d6f3ac8dd078914213cb4bb489974bcbb92ec38 /innobase | |
parent | 784191d9cec94721afb927a891bce77fc4797f30 (diff) | |
download | mariadb-git-238b226f2626573021103872b85d54a79c5743ea.tar.gz |
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.
innobase/include/srv0srv.h:
Added srv_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option.
innobase/row/row0sel.c:
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/srv/srv0srv.c:
Added srv_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option.
sql/ha_innodb.cc:
Added innobase_locks_unsafe_for_binlog and srv_locks_unsafe_for_binlog for
innodb_locks_unsafe_for_binlog option.
sql/ha_innodb.h:
Added innobase_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option.
sql/mysqld.cc:
Added OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG, innobase_locks_unsafe_for_binlog for
innodb_locks_unsafe_for_binlog option.
sql/set_var.cc:
Added innodb_locks_unsafe_for_binlog and innobase_locks_unsafe_for_binlog for
innodb_locks_unsafe_for_binlog option.
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/include/srv0srv.h | 1 | ||||
-rw-r--r-- | innobase/row/row0sel.c | 83 | ||||
-rw-r--r-- | innobase/srv/srv0srv.c | 4 |
3 files changed, 81 insertions, 7 deletions
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index c527d40bc79..b98223cff68 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -42,6 +42,7 @@ extern char* srv_arch_dir; #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; diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 8a0da2851a7..bf7f6f1fc3a 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -631,10 +631,24 @@ row_sel_get_clust_rec( 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 @@ rec_loop: 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 @@ rec_loop: 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 @@ rec_loop: /* 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 @@ rec_loop: 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) { diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index fc46c95a8a6..4c305a76547 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -74,6 +74,10 @@ ibool srv_file_per_table = FALSE; /* store to its own file each table 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 */ |