1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Acquire global read lock (MDL_BACKUP_STMT) after share is acquired

Part of MDEV-5336 Implement LOCK FOR BACKUP

FLUSH TABLE table_names have changed slighty as we are now opening
tables before taking the MDL lock. The difference is that FLUSH TABLE
table_name will now be blocked by a table that is waiting for FTWRL.
There should not be any new deadlocks as part of this change.

The end result is still better in most cases as FTWRL is now only
waiting for write statements to end, not for read only statements and
it's not flushing tables in use from the table cache.

Share will be needed to be able to determine if table supports online
backup. Appropriate metadata lock type in BACKUP namespace will be
acquired basing on this information.

Also made pending global read lock request to be preferred victim of MDL
deadlock detector. This allows us to hide some non-fatal deadlocks and
make FTWRL less likely to break concurrent queries.
This commit is contained in:
Sergey Vojtovich
2018-10-30 02:00:46 +04:00
committed by Monty
parent 7a9dfdd8d9
commit f1867505a6
8 changed files with 278 additions and 69 deletions

View File

@ -392,8 +392,13 @@ let $wait_condition=
--echo # waiting for release of read lock
connection con4;
--echo # would hang and later cause a deadlock
flush tables t2;
--send flush tables t2
connection con1;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table metadata lock" and
info = "flush tables t2";
--source include/wait_condition.inc
--echo # clean up
unlock tables;
connection con2;
@ -401,6 +406,8 @@ connection con2;
unlock tables;
connection con3;
--reap
connection con4;
--reap
connection default;
disconnect con5;
disconnect con4;
@ -437,11 +444,18 @@ let $wait_condition=
--source include/wait_condition.inc
--echo # statement is waiting for release of read lock
connection con2;
flush table t2;
--send flush table t2
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table metadata lock" and
info = "flush table t2";
--source include/wait_condition.inc
unlock tables;
connection con1;
--reap
connection con2;
--reap
--echo #
--echo # LOCK TABLES .. WRITE
@ -553,11 +567,11 @@ let $wait_condition=
where state = "Waiting for backup lock" and
info = "flush tables with read lock";
--source include/wait_condition.inc
--send insert into t1 values (1,2);
--send insert into t1 values (1,2)
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for backup lock" and
where state = "Waiting for table metadata lock" and
info = "insert into t1 values (1,2)";
--source include/wait_condition.inc
unlock tables;