diff options
author | Monty <monty@mariadb.org> | 2020-07-20 15:19:25 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-07-21 12:42:42 +0300 |
commit | fc48c8ff4c6cb9aa7a0fd27e724e6e3acd555b0e (patch) | |
tree | 14b8ef527d76e830ee649c867c8709edfca8b34f /sql/mdl.h | |
parent | c4d5b6b157b06fe22fd7e01967d7a0194c3686a2 (diff) | |
download | mariadb-git-fc48c8ff4c6cb9aa7a0fd27e724e6e3acd555b0e.tar.gz |
MDEV-21953 deadlock between BACKUP STAGE BLOCK_COMMIT and parallel repl.
The issue was:
T1, a parallel slave worker thread, is waiting for another worker thread to
commit. While waiting, it has the MDL_BACKUP_COMMIT lock.
T2, working for mariabackup, is doing BACKUP STAGE BLOCK_COMMIT and blocks
all commits.
This causes a deadlock as the thread T1 is waiting for can't commit.
Fixed by moving locking of MDL_BACKUP_COMMIT from ha_commit_trans() to
commit_one_phase_2()
Other things:
- Added a new argument to ha_comit_one_phase() to signal if the
transaction was a write transaction.
- Ensured that ha_maria::implicit_commit() is always called under
MDL_BACKUP_COMMIT. This code is not needed in 10.5
- Ensure that MDL_Request values 'type' and 'ticket' are always
initialized. This makes it easier to check the state of the MDL_Request.
- Moved thd->store_globals() earlier in handle_rpl_parallel_thread() as
thd->init_for_queries() could use a MDL that could crash if store_globals
where not called.
- Don't call ha_enable_transactions() in THD::init_for_queries() as this
is both slow (uses MDL locks) and not needed.
Diffstat (limited to 'sql/mdl.h')
-rw-r--r-- | sql/mdl.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/mdl.h b/sql/mdl.h index b084670e5c6..123ffbcade6 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -122,6 +122,8 @@ public: */ enum enum_mdl_type { + /* This means that the MDL_request is not initialized */ + MDL_NOT_INITIALIZED= -1, /* An intention exclusive metadata lock (IX). Used only for scoped locks. Owner of this type of lock can acquire upgradable exclusive locks on @@ -592,12 +594,13 @@ public: */ MDL_request& operator=(const MDL_request &) { + type= MDL_NOT_INITIALIZED; ticket= NULL; /* Do nothing, in particular, don't try to copy the key. */ return *this; } /* Another piece of ugliness for TABLE_LIST constructor */ - MDL_request() {} + MDL_request(): type(MDL_NOT_INITIALIZED), ticket(NULL) {} MDL_request(const MDL_request *rhs) :type(rhs->type), |