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