summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2019-05-02 20:06:03 +0300
committerMonty <monty@mariadb.org>2019-05-02 20:14:17 +0300
commit186635392dd530867dd3f84fca2fe451915e039b (patch)
treef2eda17c570a43e3223136c78b8f65296617b32f /sql/lock.cc
parent0cc7c6085e2caa71ad21eca6f19f5cca45457660 (diff)
downloadmariadb-git-186635392dd530867dd3f84fca2fe451915e039b.tar.gz
Fixed deadlock in main.flush_read_lock
local_global_read_lock did release all HANDLER's before taking its MDL_BACKUP_FTWRL# locks. This had a potential race condition if there was a waiting LOCK TABLE for one of the freed handlers. Fixed by moving the release of HANDLER's to after the backup locks are taken. After commit 8cf7e3459 it's not anymore critical to free HANDLER's in FTWRL, but we will keep the mysql_ha_cleanup_no_free() call until 10.5 to not cause any issues with 10.4 just before it's going GA.
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index 70e5f18125e..fe745b49003 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -1034,8 +1034,6 @@ bool Global_read_lock::lock_global_read_lock(THD *thd)
DBUG_RETURN(1);
}
- mysql_ha_cleanup_no_free(thd);
-
DBUG_ASSERT(! thd->mdl_context.is_lock_owner(MDL_key::BACKUP, "", "",
MDL_BACKUP_FTWRL1));
DBUG_ASSERT(! thd->mdl_context.is_lock_owner(MDL_key::BACKUP, "", "",
@@ -1057,6 +1055,9 @@ bool Global_read_lock::lock_global_read_lock(THD *thd)
m_mdl_global_read_lock= mdl_request.ticket;
m_state= GRL_ACQUIRED;
+
+ /* Release HANDLER OPEN after we have got our MDL lock */
+ mysql_ha_cleanup_no_free(thd);
}
/*
We DON'T set global_read_lock_blocks_commit now, it will be set after