diff options
author | Jon Olav Hauglid <jon.hauglid@sun.com> | 2009-12-15 14:18:10 +0100 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@sun.com> | 2009-12-15 14:18:10 +0100 |
commit | 6331ef3efd56d995fd7a82b7325a2615750766ad (patch) | |
tree | b18a63d270707aa91224762e3bfed617d8ca964d /mysys | |
parent | 5a4f8e214c9d1ce67ea50ec360932e932d909e98 (diff) | |
download | mariadb-git-6331ef3efd56d995fd7a82b7325a2615750766ad.tar.gz |
Bug #48940 MDL deadlocks against mysql_rm_db
This deadlock would occur between two connections A and B if statements
where executed in the following way:
1) Connection A executes a DML statement against table s1.t1 with
autocommit off. This causes a shared metadata lock on s1.t1 to be
acquired. (With autocommit on, the metadata lock will be dropped once
the statment completes and the deadlock will not occour.)
2) Connection B tries to DROP DATABASE s1. This will block against the
metadata lock connection A holds on s1.t1. While blocking, connection B
will hold the LOCK_mysql_create_db mutex.
3) Connection A tries to ALTER DATABASE s1. This will block when trying
to get LOCK_mysql_create_db mutex held by connection B.
4) Deadlock between DROP DATABASE and ALTER DATABASE (which has autocommit
off).
If Connection A used an explicitly started transaction rather than having
autocommit off, this deadlock did not happen as ALTER DATABASE is
disallowed inside transactions.
This patch fixes the problem by changing ALTER DATABASE to cause an
implicit commit before executing. This will cause the metadata
lock on s1.t1 to be dropped, allowing DROP DATABASE to proceed.
This will in turn cause the LOCK_mysql_create_db mutex to be unlocked,
allowing ALTER DATABASE to proceed.
Note that SQL commands other than ALTER DATABASE that also use
LOCK_mysql_create_db, already cause an implicit commit.
Incompatible change: ALTER DATABASE (and its synonym ALTER SCHEMA)
now cause an implicit commit. This must be reflected in the
documentation.
Test case added to schema.test.
sql/sql_parse.cc:
Added CF_AUTO_COMMIT_TRANS to SQLCOM_ALTER_DB.
Removed thd->active_transaction() checks from SQLCOM_DROP_DB,
SQLCOM_ALTER_DB_UPGRADE and SQLCOM_ALTER_DB as these statements
cause an implicit commit.
Diffstat (limited to 'mysys')
0 files changed, 0 insertions, 0 deletions