From a2de378c00c17b358fa784dcca6ab4ac11b56821 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 30 Jan 2017 16:13:49 +0200 Subject: [PATCH] Add protection for reinitialization of mutex in parallel replaction Added mutex_lock/mutex_unlock of mutex that is to be destroyed in wait_for_commit::reinit() in a similar fashion that we do in ~wait_for_commit --- sql/sql_class.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 21c8d558437..6177210e576 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6516,7 +6516,13 @@ wait_for_commit::reinit() So in this case, do a re-init of the mutex. In release builds, we want to avoid the overhead of a re-init though. + + To ensure that no one is locking the mutex, we take a lock of it first. + For full explanation, see wait_for_commit::~wait_for_commit() */ + mysql_mutex_lock(&LOCK_wait_commit); + mysql_mutex_unlock(&LOCK_wait_commit); + mysql_mutex_destroy(&LOCK_wait_commit); mysql_mutex_init(key_LOCK_wait_commit, &LOCK_wait_commit, MY_MUTEX_INIT_FAST); #endif