Skip to content

Commit 6bb28e0

Browse files
committed
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.
1 parent 8c534bd commit 6bb28e0

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include/master-slave.inc
2+
[connection master]
3+
set @old_dbug=@@global.debug_dbug;
4+
set global debug_dbug='d,fail_com_register_slave';
5+
stop slave;
6+
reset slave;
7+
include/wait_for_slave_to_stop.inc
8+
start slave;
9+
stop slave;
10+
include/wait_for_slave_to_stop.inc
11+
set global debug_dbug=@old_dbug;
12+
kill DUMP_THREAD;
13+
show slave hosts;
14+
Server_id Host Port Master_id
15+
start slave;
16+
include/rpl_end.inc
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
source include/have_debug.inc;
2+
source include/have_binlog_format_mixed.inc;
3+
source include/master-slave.inc;
4+
5+
connection slave;
6+
7+
set @old_dbug=@@global.debug_dbug;
8+
set global debug_dbug='d,fail_com_register_slave';
9+
10+
stop slave;
11+
reset slave;
12+
source include/wait_for_slave_to_stop.inc;
13+
start slave;
14+
stop slave;
15+
source include/wait_for_slave_to_stop.inc;
16+
set global debug_dbug=@old_dbug;
17+
18+
connection master;
19+
20+
### why is that needed?
21+
let $id=`SELECT id from information_schema.processlist where command='Binlog Dump'`;
22+
if ($id) {
23+
replace_result $id DUMP_THREAD;
24+
eval kill $id;
25+
let $wait_condition= SELECT count(*)=0 from information_schema.processlist where command='Binlog Dump';
26+
source include/wait_condition.inc;
27+
}
28+
29+
show slave hosts;
30+
31+
connection slave;
32+
start slave;
33+
source include/rpl_end.inc;

sql/slave.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,7 @@ pthread_handler_t handle_slave_io(void *arg)
31793179
goto err;
31803180
goto connected;
31813181
}
3182+
DBUG_EXECUTE_IF("fail_com_register_slave", goto err;);
31823183
}
31833184

31843185
DBUG_PRINT("info",("Starting reading binary log from master"));

sql/sql_class.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "sql_parse.h" // is_update_query
6464
#include "sql_callback.h"
6565
#include "sql_connect.h"
66+
#include "repl_failsafe.h"
6667

6768
/*
6869
The following is used to initialise Table_ident with a internal
@@ -1496,6 +1497,7 @@ THD::~THD()
14961497
if (rli_slave)
14971498
rli_slave->cleanup_after_session();
14981499
my_free(semisync_info);
1500+
unregister_slave(this, true, true);
14991501
#endif
15001502

15011503
free_root(&main_mem_root, MYF(0));

sql/sql_parse.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
12691269
general_log_print(thd, command, "Log: '%s' Pos: %lu", name, pos);
12701270
if (nlen < FN_REFLEN)
12711271
mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags);
1272-
unregister_slave(thd,1,1);
12731272
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
12741273
error = TRUE;
12751274
break;

0 commit comments

Comments
 (0)