summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjonas@perch.ndb.mysql.com <>2006-09-04 13:43:34 +0200
committerjonas@perch.ndb.mysql.com <>2006-09-04 13:43:34 +0200
commit96ff8b4c521aba696ba62154605ea2a04a927c6e (patch)
tree2f11faf90e49ea4e1e47cec032231077bb5adbfd
parentb60be73461bb295b8b797a49c1a1b8b97baa55fe (diff)
downloadmariadb-git-96ff8b4c521aba696ba62154605ea2a04a927c6e.tar.gz
bug#21965 - replication
fix deadlock if master switches log file in parallell with "show master logs"
-rw-r--r--sql/log.cc9
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_repl.cc8
3 files changed, 14 insertions, 4 deletions
diff --git a/sql/log.cc b/sql/log.cc
index c530f15a84f..5ae89dfeb50 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -409,13 +409,18 @@ shutdown the MySQL server and restart it.", log_name, errno);
int MYSQL_LOG::get_current_log(LOG_INFO* linfo)
{
pthread_mutex_lock(&LOCK_log);
+ int ret = raw_get_current_log(linfo);
+ pthread_mutex_unlock(&LOCK_log);
+ return ret;
+}
+
+int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
+{
strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
linfo->pos = my_b_tell(&log_file);
- pthread_mutex_unlock(&LOCK_log);
return 0;
}
-
/*
Move all data up in a file in an filename index file
diff --git a/sql/sql_class.h b/sql/sql_class.h
index e8fe175cd7c..a995a492bc8 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -177,6 +177,7 @@ public:
bool need_mutex);
int find_next_log(LOG_INFO* linfo, bool need_mutex);
int get_current_log(LOG_INFO* linfo);
+ int raw_get_current_log(LOG_INFO* linfo);
uint next_file_id();
inline bool is_open() { return log_type != LOG_CLOSED; }
inline char* get_index_fname() { return index_file_name;}
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 963c4ccf5a6..2a7ab55b8c4 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1359,10 +1359,14 @@ int show_binlogs(THD* thd)
MYSQL_TYPE_LONGLONG));
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(1);
+
+ pthread_mutex_lock(mysql_bin_log.get_log_lock());
mysql_bin_log.lock_index();
index_file=mysql_bin_log.get_index_file();
-
- mysql_bin_log.get_current_log(&cur);
+
+ mysql_bin_log.raw_get_current_log(&cur); // dont take mutex
+ pthread_mutex_unlock(mysql_bin_log.get_log_lock()); // lockdep, OK
+
cur_dir_len= dirname_length(cur.log_file_name);
reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0);