diff options
author | unknown <guilhem@mysql.com> | 2004-08-20 16:35:23 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-08-20 16:35:23 +0200 |
commit | cd8054d4318077827bcf20e640af6fcddf1d9525 (patch) | |
tree | 9d89f6beb28a1d747c302488d23cb8d5bfca7507 /mysql-test | |
parent | f758ada4bcfdf9b22b1603bc273b5e2a6436037b (diff) | |
download | mariadb-git-cd8054d4318077827bcf20e640af6fcddf1d9525.tar.gz |
Making FLUSH TABLES WITH READ LOCK block COMMITs of existing transactions,
in a deadlock-free manner. This splits locking the global read lock in two steps.
This fixes a consequence of this bug, known as:
BUG#4953 'mysqldump --master-data may report incorrect binlog position if using InnoDB'
And a test.
sql/handler.cc:
making COMMIT wait if FLUSH TABLES WITH READ LOCK happened.
sql/lock.cc:
an additional stage so that FLUSH TABLES WITH READ LOCK blocks COMMIT:
make_global_read_lock_block_commit():
taking the global read lock is TWO steps (2nd step is optional; without
it, COMMIT of existing transactions will be allowed):
lock_global_read_lock() THEN make_global_read_lock_block_commit().
sql/mysql_priv.h:
new argument to wait_if_global_read_lock()
sql/sql_class.h:
THD::global_read_lock now an uint to reflect the 2 steps of global read lock (does not block COMMIT / does)
sql/sql_db.cc:
update for new prototype
sql/sql_parse.cc:
implementing the two steps of global read lock so that FLUSH TABLES WITH READ LOCK can block COMMIT without deadlocking with COMMITs.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/flush_block_commit.result | 23 | ||||
-rw-r--r-- | mysql-test/t/flush_block_commit-master.opt | 1 | ||||
-rw-r--r-- | mysql-test/t/flush_block_commit.test | 49 |
3 files changed, 73 insertions, 0 deletions
diff --git a/mysql-test/r/flush_block_commit.result b/mysql-test/r/flush_block_commit.result new file mode 100644 index 00000000000..3205dd9dad9 --- /dev/null +++ b/mysql-test/r/flush_block_commit.result @@ -0,0 +1,23 @@ +drop table if exists t1; +create table t1 (a int) type=innodb; +begin; +insert into t1 values(1); +flush tables with read lock; +select * from t1; +a + commit; +select * from t1; +a +unlock tables; +begin; +select * from t1 for update; +a +1 +begin; + select * from t1 for update; + flush tables with read lock; +commit; +a +1 +unlock tables; +drop table t1; diff --git a/mysql-test/t/flush_block_commit-master.opt b/mysql-test/t/flush_block_commit-master.opt new file mode 100644 index 00000000000..d1f6d58e9f7 --- /dev/null +++ b/mysql-test/t/flush_block_commit-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=5 diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test new file mode 100644 index 00000000000..20ecec1361c --- /dev/null +++ b/mysql-test/t/flush_block_commit.test @@ -0,0 +1,49 @@ +# Let's see if FLUSH TABLES WITH READ LOCK blocks COMMIT of existing +# transactions. +# We verify that we did not introduce a deadlock. + +-- source include/have_innodb.inc + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +connect (con3,localhost,root,,); +connection con1; +drop table if exists t1; +create table t1 (a int) type=innodb; + +# blocks COMMIT ? + +begin; +insert into t1 values(1); +connection con2; +flush tables with read lock; +select * from t1; +connection con1; +send commit; # blocked by con2 +sleep 1; +connection con2; +select * from t1; # verify con1 was blocked and data did not move +unlock tables; +connection con1; +reap; + +# No deadlock ? + +connection con1; +begin; +select * from t1 for update; +connection con2; +begin; +send select * from t1 for update; # blocked by con1 +sleep 1; +connection con3; +send flush tables with read lock; # blocked by con2 +connection con1; +commit; # should not be blocked by con3 +connection con2; +reap; +connection con3; +reap; +unlock tables; +connection con1; +drop table t1; |