mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 22:12:30 +01:00
218bf86cd9
sporadically". Races in truncate_coverage.test have caused its sporadical failures. In the test case we have tried to kill truncate statement being executed in the first connection which was waiting for X metadata lock on table being locked by the second connection. Since we have released metadata lock held by the second connection right after issuing KILL statement sometimes TRUNCATE TABLE managed to acquire X lock before it has noticed that it was killed. In this case TRUNCATE TABLE was successfully executed till its end and this fact has caused test failure since this statement didn't return expected error in such case. This patch addresses the problem by not releasing metadata locks in the second connections prematurely.
80 lines
1.6 KiB
Text
80 lines
1.6 KiB
Text
SET DEBUG_SYNC='RESET';
|
|
DROP TABLE IF EXISTS t1;
|
|
#
|
|
# Bug#20667 - Truncate table fails for a write locked table
|
|
#
|
|
CREATE TABLE t1 (c1 INT);
|
|
INSERT INTO t1 VALUES (1);
|
|
#
|
|
# connection con1
|
|
HANDLER t1 OPEN;
|
|
#
|
|
# connection default
|
|
LOCK TABLE t1 WRITE;
|
|
SET DEBUG_SYNC='mdl_upgrade_shared_lock_to_exclusive SIGNAL waiting';
|
|
TRUNCATE TABLE t1;
|
|
#
|
|
# connection con2
|
|
SET DEBUG_SYNC='now WAIT_FOR waiting';
|
|
KILL QUERY @id;
|
|
#
|
|
# connection default
|
|
ERROR 70100: Query execution was interrupted
|
|
UNLOCK TABLES;
|
|
#
|
|
# connection con1
|
|
# Release shared metadata lock by closing HANDLER.
|
|
HANDLER t1 CLOSE;
|
|
#
|
|
# connection default
|
|
DROP TABLE t1;
|
|
SET DEBUG_SYNC='RESET';
|
|
CREATE TABLE t1 (c1 INT);
|
|
INSERT INTO t1 VALUES (1);
|
|
#
|
|
# connection con1
|
|
HANDLER t1 OPEN;
|
|
#
|
|
# connection default
|
|
LOCK TABLE t1 WRITE;
|
|
SET DEBUG_SYNC='mdl_upgrade_shared_lock_to_exclusive SIGNAL waiting';
|
|
TRUNCATE TABLE t1;
|
|
#
|
|
# connection con2
|
|
SET DEBUG_SYNC='now WAIT_FOR waiting';
|
|
#
|
|
# connection con1
|
|
HANDLER t1 CLOSE;
|
|
#
|
|
# connection default
|
|
ERROR 42S02: Table 'test.t1' doesn't exist
|
|
UNLOCK TABLES;
|
|
DROP TABLE t1;
|
|
ERROR 42S02: Unknown table 't1'
|
|
SET DEBUG_SYNC='RESET';
|
|
CREATE TABLE t1 (c1 INT);
|
|
INSERT INTO t1 VALUES (1);
|
|
#
|
|
# connection con1
|
|
START TRANSACTION;
|
|
INSERT INTO t1 VALUES (2);
|
|
#
|
|
# connection default
|
|
SET DEBUG_SYNC='mdl_acquire_lock_wait SIGNAL waiting';
|
|
TRUNCATE TABLE t1;
|
|
#
|
|
# connection con1
|
|
SET DEBUG_SYNC='now WAIT_FOR waiting';
|
|
KILL QUERY @id;
|
|
#
|
|
# connection default
|
|
ERROR 70100: Query execution was interrupted
|
|
#
|
|
# connection con1
|
|
# Release SW lock by committing transaction.
|
|
COMMIT;
|
|
#
|
|
# connection default
|
|
UNLOCK TABLES;
|
|
DROP TABLE t1;
|
|
SET DEBUG_SYNC='RESET';
|