summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-04-28 14:59:47 +0200
committerSergei Golubchik <serg@mariadb.org>2020-04-30 10:13:18 +0200
commit6bb28e0bc52d415619ad33c60c05dfa2794a5412 (patch)
tree5641c6a2841a35c5fd71216c9fb53fc54901b103
parent8c534bdeb8c50bc1df088feca10ea0585f73a46e (diff)
downloadmariadb-git-6bb28e0bc52d415619ad33c60c05dfa2794a5412.tar.gz
Bug#29915479 RUNNING COM_REGISTER_SLAVE WITHOUT COM_BINLOG_DUMP CAN RESULTS IN SERVER EXIT
in fact, in MariaDB it cannot, but it can show spurious slaves in SHOW SLAVE HOSTS. slave was registered in COM_REGISTER_SLAVE and un-registered after COM_BINLOG_DUMP. If there was no COM_BINLOG_DUMP, it would never unregister.
-rw-r--r--mysql-test/suite/rpl/r/rpl_fail_register.result16
-rw-r--r--mysql-test/suite/rpl/t/rpl_fail_register.test33
-rw-r--r--sql/slave.cc1
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_parse.cc1
5 files changed, 52 insertions, 1 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_fail_register.result b/mysql-test/suite/rpl/r/rpl_fail_register.result
new file mode 100644
index 00000000000..4e433636ad9
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_fail_register.result
@@ -0,0 +1,16 @@
+include/master-slave.inc
+[connection master]
+set @old_dbug=@@global.debug_dbug;
+set global debug_dbug='d,fail_com_register_slave';
+stop slave;
+reset slave;
+include/wait_for_slave_to_stop.inc
+start slave;
+stop slave;
+include/wait_for_slave_to_stop.inc
+set global debug_dbug=@old_dbug;
+kill DUMP_THREAD;
+show slave hosts;
+Server_id Host Port Master_id
+start slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_fail_register.test b/mysql-test/suite/rpl/t/rpl_fail_register.test
new file mode 100644
index 00000000000..bfecc9d7f14
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_fail_register.test
@@ -0,0 +1,33 @@
+source include/have_debug.inc;
+source include/have_binlog_format_mixed.inc;
+source include/master-slave.inc;
+
+connection slave;
+
+set @old_dbug=@@global.debug_dbug;
+set global debug_dbug='d,fail_com_register_slave';
+
+stop slave;
+reset slave;
+source include/wait_for_slave_to_stop.inc;
+start slave;
+stop slave;
+source include/wait_for_slave_to_stop.inc;
+set global debug_dbug=@old_dbug;
+
+connection master;
+
+### why is that needed?
+let $id=`SELECT id from information_schema.processlist where command='Binlog Dump'`;
+if ($id) {
+ replace_result $id DUMP_THREAD;
+ eval kill $id;
+ let $wait_condition= SELECT count(*)=0 from information_schema.processlist where command='Binlog Dump';
+ source include/wait_condition.inc;
+}
+
+show slave hosts;
+
+connection slave;
+start slave;
+source include/rpl_end.inc;
diff --git a/sql/slave.cc b/sql/slave.cc
index d359e1bdae4..add75e281a8 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3179,6 +3179,7 @@ connected:
goto err;
goto connected;
}
+ DBUG_EXECUTE_IF("fail_com_register_slave", goto err;);
}
DBUG_PRINT("info",("Starting reading binary log from master"));
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 96d56bfda17..a665cd6522e 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -63,6 +63,7 @@
#include "sql_parse.h" // is_update_query
#include "sql_callback.h"
#include "sql_connect.h"
+#include "repl_failsafe.h"
/*
The following is used to initialise Table_ident with a internal
@@ -1496,6 +1497,7 @@ THD::~THD()
if (rli_slave)
rli_slave->cleanup_after_session();
my_free(semisync_info);
+ unregister_slave(this, true, true);
#endif
free_root(&main_mem_root, MYF(0));
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index ae5a6b4cd35..82dbe809c7d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1269,7 +1269,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
general_log_print(thd, command, "Log: '%s' Pos: %lu", name, pos);
if (nlen < FN_REFLEN)
mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags);
- unregister_slave(thd,1,1);
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
error = TRUE;
break;