1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-19544 Remove innodb_locks_unsafe_for_binlog

The transaction isolation levels READ COMMITTED and READ UNCOMMITTED
should behave similarly to the old deprecated setting
innodb_locks_unsafe_for_binlog=1, that is, avoid acquiring gap locks.

row_search_mvcc(): Reduce the scope of some variables, and clean up
the initialization and use of the variable set_also_gap_locks.
This commit is contained in:
Marko Mäkelä
2019-05-22 14:49:38 +03:00
parent 47cede646b
commit 1a6f470464
29 changed files with 158 additions and 484 deletions

View File

@ -31,20 +31,19 @@ SET SQL_MODE="";
# Show prerequisites for this test.
#
SELECT @@global.tx_isolation;
SELECT @@global.innodb_locks_unsafe_for_binlog;
#
# When innodb_locks_unsafe_for_binlog is not set (zero), which is the
# default, InnoDB takes "next-key locks"/"gap locks". This means it
# With the transaction isolation level REPEATABLE READ (the default)
# or SERIALIZEBLE, InnoDB takes "next-key locks"/"gap locks". This means it
# locks the gap before the keys that it accessed to find the rows to
# use for a statement. In this case we have to expect some more lock
# wait timeouts in the tests below as if innodb_locks_unsafe_for_binlog
# is set (non-zero). In the latter case no "next-key locks"/"gap locks"
# are taken and locks on keys that do not match the WHERE conditon are
# released. Hence less lock collisions occur.
# wait timeouts in the tests, compared to READ UNCOMMITTED or READ COMMITTED.
# For READ UNCOMMITTED or READ COMMITTED, no "next-key locks"/"gap locks"
# are taken and locks on keys that do not match the WHERE condition are
# released. Hence fewer lock collisions occur.
# We use the variable $keep_locks to set the expectations for
# lock wait timeouts accordingly.
#
let $keep_locks= `SELECT NOT @@global.innodb_locks_unsafe_for_binlog`;
let $keep_locks= `SELECT @@global.tx_isolation IN ('REPEATABLE-READ','SERIALIZABLE')`;
--echo # keep_locks == $keep_locks
#
@ -52,14 +51,6 @@ let $keep_locks= `SELECT NOT @@global.innodb_locks_unsafe_for_binlog`;
#
GRANT USAGE ON test.* TO mysqltest@localhost;
#
# Preparatory cleanup.
#
--disable_warnings
drop table if exists t1;
--enable_warnings
--echo
--echo **
--echo ** two UPDATE's running and both changing distinct result sets
@ -99,7 +90,7 @@ drop table if exists t1;
--echo ** Update on t1 will cause a table scan which will be blocked because
--echo ** the previously initiated table scan applied exclusive key locks on
--echo ** all primary keys.
--echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
--echo ** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that
--echo ** do not match the WHERE condition are released.
if ($keep_locks)
{
@ -190,7 +181,7 @@ drop table t1;
--echo ** Update on t1 will cause a table scan which will be blocked because
--echo ** the previously initiated table scan applied exclusive key locks on
--echo ** all primary keys.
--echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
--echo ** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that
--echo ** do not match the WHERE condition are released.
if ($keep_locks)
{
@ -386,7 +377,7 @@ drop table t1;
--echo ** Updating single row using a table scan. This will time out
--echo ** because of ongoing transaction on thread 1 holding lock on
--echo ** all primary keys in the scan.
--echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
--echo ** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that
--echo ** do not match the WHERE condition are released.
if ($keep_locks)
{
@ -570,7 +561,7 @@ drop table t1;
--echo ** Update on t1 will cause a table scan which will be blocked because
--echo ** the previously initiated table scan applied exclusive key locks on
--echo ** all primary keys.
--echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
--echo ** Not so for READ UNCOMMITTED or READ COMMITTED. The locks that
--echo ** do not match the WHERE condition are released.
if ($keep_locks)
{
@ -598,13 +589,8 @@ drop table t1;
connection thread1;
select * from t1;
--echo ** Cleanup
connection thread1;
disconnect thread1;
--source include/wait_until_disconnected.inc
connection thread2;
disconnect thread2;
--source include/wait_until_disconnected.inc
connection default;
drop table t1;
drop user mysqltest@localhost;