1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

Bug #52593 SHOW CREATE TABLE is blocked if table is locked

for write by another connection

The problem was that if a table was locked in one connection by
LOCK TABLES ... WRITE, REPAIR TABLE or OPTIMIZE TABLE, SHOW CREATE
TABLE from another connection would be blocked. As SHOW CREATE TABLE
only reads metadata about the table, such blocking is not needed.

The problem was that when SHOW CREATE TABLE tried to get a metadata
lock on the table in order to open it, it used the wrong type of
metadata lock request. It used MDL_SHARED_READ which is used when
the intent is to read both table metadata and table data. Instead
it should have used MDL_SHARED_HIGH_PRIO which signifies an intent
to only read metadata.

This patch fixes the problem by making sure SHOW CREATE TABLE uses
the MDL_SHARED_HIGH_PRIO metadata lock request type when trying to
open the table. The patch also fixes a similar problem with the
mysql_list_fields API call.

Test case added to show_check.test.
This commit is contained in:
Jon Olav Hauglid
2010-04-14 09:40:45 +02:00
parent 7e6eddd374
commit d18275c2c2
3 changed files with 50 additions and 4 deletions

View File

@@ -1448,3 +1448,20 @@ DROP USER test_u@localhost;
SHOW CREATE TABLE non_existent;
ERROR 70100: Query execution was interrupted
End of 5.1 tests
#
# Bug#52593 SHOW CREATE TABLE is blocked if table is locked
# for write by another connection
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT PRIMARY KEY);
LOCK TABLE t1 WRITE;
# Switching to connection 'con1'.
# This statement used to be blocked.
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL,
PRIMARY KEY (`i`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Switching to connection 'default'.
UNLOCK TABLES;
DROP TABLE t1;

View File

@@ -1212,6 +1212,32 @@ DISCONNECT con1;
--echo End of 5.1 tests
--echo #
--echo # Bug#52593 SHOW CREATE TABLE is blocked if table is locked
--echo # for write by another connection
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
connect(con1, localhost,root);
connection default;
CREATE TABLE t1 (i INT PRIMARY KEY);
LOCK TABLE t1 WRITE;
--echo # Switching to connection 'con1'.
connection con1;
--echo # This statement used to be blocked.
SHOW CREATE TABLE t1;
--echo # Switching to connection 'default'.
connection default;
disconnect con1;
UNLOCK TABLES;
DROP TABLE t1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc