summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorSven Sandberg <sven.sandberg@oracle.com>2011-05-26 12:50:43 +0200
committerSven Sandberg <sven.sandberg@oracle.com>2011-05-26 12:50:43 +0200
commitb76c277a8f46f7e1047099df4686cb06c26a08fa (patch)
tree0e832d27e21a2b34abfb7f7e0894140570d2528f /sql/log.cc
parentaa0c8235a4fed513982cf3f576184404cf357826 (diff)
downloadmariadb-git-b76c277a8f46f7e1047099df4686cb06c26a08fa.tar.gz
BUG#12574820: binlog.binlog_tmp_table timing out in daily and weekly trunk run
Problem: MYSQL_BIN_LOG::reset_logs acquires mutexes in wrong order. The correct order is first LOCK_thread_count and then LOCK_log. This function does it the other way around. This leads to deadlock when run in parallel with a thread that takes the two locks in correct order. For example, a thread that disconnects will take the locks in the correct order. Fix: change order of the locks in MYSQL_BIN_LOG::reset_logs: first LOCK_thread_count and then LOCK_log.
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 17642696e7d..77d12641442 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2989,12 +2989,6 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
DBUG_ENTER("reset_logs");
ha_reset_logs(thd);
- /*
- We need to get both locks to be sure that no one is trying to
- write to the index log file.
- */
- pthread_mutex_lock(&LOCK_log);
- pthread_mutex_lock(&LOCK_index);
/*
The following mutex is needed to ensure that no threads call
@@ -3002,7 +2996,14 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
thread. If the transaction involved MyISAM tables, it should go
into binlog even on rollback.
*/
- VOID(pthread_mutex_lock(&LOCK_thread_count));
+ pthread_mutex_lock(&LOCK_thread_count);
+
+ /*
+ We need to get both locks to be sure that no one is trying to
+ write to the index log file.
+ */
+ pthread_mutex_lock(&LOCK_log);
+ pthread_mutex_lock(&LOCK_index);
/* Save variables so that we can reopen the log */
save_name=name;