summaryrefslogtreecommitdiff
path: root/sql/rpl_mi.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-09-06 08:33:56 +0200
committerSergei Golubchik <sergii@pisem.net>2014-09-06 08:33:56 +0200
commit3da761912a6b243b1361a27d5b796cc53dfff3ec (patch)
treec566c164d2499b28b18ffee1dc4f3c32f5c8a8bd /sql/rpl_mi.cc
parent9392d0e280c622c56d1b533762d8b577ed5b82c6 (diff)
downloadmariadb-git-3da761912a6b243b1361a27d5b796cc53dfff3ec.tar.gz
MDEV-6616 Server crashes in my_hash_first if shutdown is performed when FLUSH LOGS is running
master_info_index becomes zero during shutdown. check that it's valid (under a mutex) before dereferencing.
Diffstat (limited to 'sql/rpl_mi.cc')
-rw-r--r--sql/rpl_mi.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index f2c39ea7f8d..78218e0418e 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -891,6 +891,9 @@ bool Master_info_index::init_all_master_info()
File index_file_nr;
DBUG_ENTER("init_all_master_info");
+ mysql_mutex_assert_owner(&LOCK_active_mi);
+ DBUG_ASSERT(master_info_index);
+
if ((index_file_nr= my_open(index_file_name,
O_RDWR | O_CREAT | O_BINARY ,
MYF(MY_WME | ME_NOREFRESH))) < 0 ||
@@ -1090,6 +1093,10 @@ Master_info_index::get_master_info(LEX_STRING *connection_name,
("connection_name: '%.*s'", (int) connection_name->length,
connection_name->str));
+ mysql_mutex_assert_owner(&LOCK_active_mi);
+ if (!this) // master_info_index is set to NULL on server shutdown
+ return NULL;
+
/* Make name lower case for comparison */
res= strmake(buff, connection_name->str, connection_name->length);
my_casedn_str(system_charset_info, buff);
@@ -1117,6 +1124,9 @@ bool Master_info_index::check_duplicate_master_info(LEX_STRING *name_arg,
Master_info *mi;
DBUG_ENTER("check_duplicate_master_info");
+ mysql_mutex_assert_owner(&LOCK_active_mi);
+ DBUG_ASSERT(master_info_index);
+
/* Get full host and port name */
if ((mi= master_info_index->get_master_info(name_arg,
Sql_condition::WARN_LEVEL_NOTE)))
@@ -1239,6 +1249,8 @@ bool Master_info_index::give_error_if_slave_running()
{
DBUG_ENTER("warn_if_slave_running");
mysql_mutex_assert_owner(&LOCK_active_mi);
+ if (!this) // master_info_index is set to NULL on server shutdown
+ return TRUE;
for (uint i= 0; i< master_info_hash.records; ++i)
{