mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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
This commit is contained in:
@ -61,6 +61,7 @@ hf@genie.(none)
|
||||
igor@hundin.mysql.fi
|
||||
igor@rurik.mysql.com
|
||||
ingo@mysql.com
|
||||
jan@hundin.mysql.fi
|
||||
jani@a80-186-24-72.elisa-laajakaista.fi
|
||||
jani@dsl-jkl1657.dial.inet.fi
|
||||
jani@dsl-kpogw4gb5.dial.inet.fi
|
||||
|
@ -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;
|
||||
|
@ -632,9 +632,23 @@ 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) {
|
||||
|
@ -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 */
|
||||
|
@ -117,6 +117,7 @@ my_bool innobase_log_archive = FALSE;/* unused */
|
||||
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 @@ innobase_init(void)
|
||||
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;
|
||||
|
||||
|
@ -189,7 +189,7 @@ extern char *innobase_unix_file_flush_method;
|
||||
/* 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;
|
||||
}
|
||||
|
@ -3880,6 +3880,7 @@ enum options_mysqld
|
||||
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 @@ Disable with --skip-bdb (will save memory).",
|
||||
"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,
|
||||
|
@ -673,6 +673,7 @@ struct show_var_st init_vars[]= {
|
||||
{"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 },
|
||||
|
Reference in New Issue
Block a user