Below is the list of changes that have just been committed into a local
4.1 repository of mydev. When mydev 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://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2361 05/08/05 15:37:24 ingo@stripped +3 -0
Bug#9459 - deadlock with flush with lock, and lock table write
Added a check before taking a global read lock if
the own thread has a write locked table.
sql/sql_parse.cc
1.456 05/08/05 15:37:18 ingo@stripped +17 -0
Bug#9459 - deadlock with flush with lock, and lock table write
Added a check before taking a global read lock if
the own thread has a write locked table.
mysql-test/t/flush.test
1.16 05/08/05 15:37:18 ingo@stripped +31 -0
Bug#9459 - deadlock with flush with lock, and lock table write
The test case.
mysql-test/r/flush.result
1.12 05/08/05 15:37:18 ingo@stripped +21 -0
Bug#9459 - deadlock with flush with lock, and lock table write
The test result.
# 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: ingo
# Host: chilla.local
# Root: /home/mydev/mysql-4.1-4100
--- 1.455/sql/sql_parse.cc 2005-08-02 02:12:27 +02:00
+++ 1.456/sql/sql_parse.cc 2005-08-05 15:37:18 +02:00
@@ -5028,6 +5028,23 @@
if ((options & REFRESH_READ_LOCK) && thd)
{
/*
+ We must not try to aspire a global read lock if we have a write
+ locked table. This would lead to a deadlock when trying to
+ reopen (and re-lock) the table after the flush.
+ */
+ if (thd->locked_tables)
+ {
+ THR_LOCK_DATA **lock_p= thd->locked_tables->locks;
+ THR_LOCK_DATA **end_p= lock_p + thd->locked_tables->lock_count;
+
+ for (; lock_p < end_p; lock_p++)
+ if ((*lock_p)->type == TL_WRITE)
+ {
+ my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+ return 1;
+ }
+ }
+ /*
Writing to the binlog could cause deadlocks, as we don't log
UNLOCK TABLES
*/
--- 1.11/mysql-test/r/flush.result 2003-08-07 20:17:21 +02:00
+++ 1.12/mysql-test/r/flush.result 2005-08-05 15:37:18 +02:00
@@ -27,3 +27,24 @@
n
345
drop table t1;
+create table t1 (c1 int);
+lock table t1 write;
+flush tables with read lock;
+ERROR HY000: Can't execute the given command because you have active locked tables or an
active transaction
+lock table t1 read;
+flush tables with read lock;
+lock table t1 write;
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+lock table t1 read;
+lock table t1 write;
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+unlock tables;
+create table t2 (c1 int);
+create table t3 (c1 int);
+lock table t1 read, t2 read, t3 write;
+flush tables with read lock;
+ERROR HY000: Can't execute the given command because you have active locked tables or an
active transaction
+lock table t1 read, t2 read, t3 read;
+flush tables with read lock;
+unlock tables;
+drop table t1, t2, t3;
--- 1.15/mysql-test/t/flush.test 2005-07-28 02:21:41 +02:00
+++ 1.16/mysql-test/t/flush.test 2005-08-05 15:37:18 +02:00
@@ -70,4 +70,35 @@
select * from t1;
drop table t1;
+#
+# Bug#9459 - deadlock with flush with lock, and lock table write
+#
+create table t1 (c1 int);
+lock table t1 write;
+# Cannot get the global read lock with write locked tables.
+--error 1192
+flush tables with read lock;
+lock table t1 read;
+# Can get the global read lock with read locked tables.
+flush tables with read lock;
+--error 1223
+lock table t1 write;
+lock table t1 read;
+--error 1223
+lock table t1 write;
+# Release all table locks and the global read lock.
+unlock tables;
+create table t2 (c1 int);
+create table t3 (c1 int);
+lock table t1 read, t2 read, t3 write;
+# Cannot get the global read lock with write locked tables.
+--error 1192
+flush tables with read lock;
+lock table t1 read, t2 read, t3 read;
+# Can get the global read lock with read locked tables.
+flush tables with read lock;
+# Release all table locks and the global read lock.
+unlock tables;
+drop table t1, t2, t3;
+
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (ingo:1.2361) BUG#9459 | ingo | 5 Aug |