Skip to content

Commit 744580d

Browse files
committed
MDEV-32892: IO Thread Reports False Error When Stopped During Connecting to Primary
The IO thread can report error code 2013 into the error log when it is stopped during the initial connection process to the primary, as well as when trying to read an event. However, because the IO thread is being stopped, its connection to the primary is force-killed by the signaling thread (see THD::awake_no_mutex()), and thereby these connection errors should be ignored. Reviewed By: ============ Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent d1e5fa8 commit 744580d

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

mysql-test/suite/rpl/r/rpl_stop_slave_error.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ include/master-slave.inc
22
[connection master]
33
connection master;
44
connection slave;
5+
# MDEV-32892: Repeatedly starting/stopping io_thread..
56
include/stop_slave.inc
67
NOT FOUND /Error reading packet from server: Lost connection/ in slave_log.err
8+
NOT FOUND /error code: 2013/ in slave_log.err
79
include/start_slave.inc
810
include/rpl_end.inc

mysql-test/suite/rpl/t/rpl_stop_slave_error.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,26 @@ source include/master-slave.inc;
66

77
connection master;
88
sync_slave_with_master;
9+
10+
--let $iter=100
11+
--echo # MDEV-32892: Repeatedly starting/stopping io_thread..
12+
--disable_query_log
13+
while ($iter)
14+
{
15+
stop slave io_thread;
16+
start slave io_thread;
17+
--dec $iter
18+
}
19+
--enable_query_log
920
source include/stop_slave.inc;
21+
1022
let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/slave_log.err;
1123
let SEARCH_PATTERN=Error reading packet from server: Lost connection;
1224
source include/search_pattern_in_file.inc;
1325

26+
let SEARCH_PATTERN=error code: 2013;
27+
source include/search_pattern_in_file.inc;
28+
1429
source include/start_slave.inc;
1530
source include/rpl_end.inc;
1631

sql/slave.cc

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,9 @@ when it try to get the value of TIME_ZONE global variable from master.";
22922292
if (unlikely(mysql_real_query(mysql,
22932293
STRING_WITH_LEN("SET skip_replication=1"))))
22942294
{
2295+
if (check_io_slave_killed(mi, NULL))
2296+
goto slave_killed_err;
2297+
22952298
err_code= mysql_errno(mysql);
22962299
if (is_network_error(err_code))
22972300
{
@@ -2336,6 +2339,9 @@ when it try to get the value of TIME_ZONE global variable from master.";
23362339
STRINGIFY_ARG(MARIA_SLAVE_CAPABILITY_MINE))));
23372340
if (unlikely(rc))
23382341
{
2342+
if (check_io_slave_killed(mi, NULL))
2343+
goto slave_killed_err;
2344+
23392345
err_code= mysql_errno(mysql);
23402346
if (is_network_error(err_code))
23412347
{
@@ -2377,6 +2383,9 @@ when it try to get the value of TIME_ZONE global variable from master.";
23772383
!(master_res= mysql_store_result(mysql)) ||
23782384
!(master_row= mysql_fetch_row(master_res)))
23792385
{
2386+
if (check_io_slave_killed(mi, NULL))
2387+
goto slave_killed_err;
2388+
23802389
err_code= mysql_errno(mysql);
23812390
if (is_network_error(err_code))
23822391
{
@@ -2412,6 +2421,9 @@ when it try to get the value of TIME_ZONE global variable from master.";
24122421
rc= mysql_real_query(mysql, query_str.ptr(), query_str.length());
24132422
if (unlikely(rc))
24142423
{
2424+
if (check_io_slave_killed(mi, NULL))
2425+
goto slave_killed_err;
2426+
24152427
err_code= mysql_errno(mysql);
24162428
if (is_network_error(err_code))
24172429
{
@@ -2445,6 +2457,9 @@ when it try to get the value of TIME_ZONE global variable from master.";
24452457
rc= mysql_real_query(mysql, query_str.ptr(), query_str.length());
24462458
if (unlikely(rc))
24472459
{
2460+
if (check_io_slave_killed(mi, NULL))
2461+
goto slave_killed_err;
2462+
24482463
err_code= mysql_errno(mysql);
24492464
if (is_network_error(err_code))
24502465
{
@@ -2478,6 +2493,9 @@ when it try to get the value of TIME_ZONE global variable from master.";
24782493
rc= mysql_real_query(mysql, query_str.ptr(), query_str.length());
24792494
if (unlikely(rc))
24802495
{
2496+
if (check_io_slave_killed(mi, NULL))
2497+
goto slave_killed_err;
2498+
24812499
err_code= mysql_errno(mysql);
24822500
if (is_network_error(err_code))
24832501
{
@@ -2514,6 +2532,9 @@ when it try to get the value of TIME_ZONE global variable from master.";
25142532
rc= mysql_real_query(mysql, query_str.ptr(), query_str.length());
25152533
if (unlikely(rc))
25162534
{
2535+
if (check_io_slave_killed(mi, NULL))
2536+
goto slave_killed_err;
2537+
25172538
err_code= mysql_errno(mysql);
25182539
if (is_network_error(err_code))
25192540
{
@@ -3658,7 +3679,7 @@ static ulong read_event(MYSQL* mysql, Master_info *mi, bool* suppress_warnings,
36583679
}
36593680
else
36603681
{
3661-
if (!mi->rli.abort_slave)
3682+
if (!(mi->rli.abort_slave || io_slave_killed(mi)))
36623683
{
36633684
sql_print_error("Error reading packet from server: %s (server_errno=%d)",
36643685
mysql_error(mysql), mysql_errno(mysql));
@@ -7432,7 +7453,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
74327453
mi->port, 0, client_flag) == 0))
74337454
{
74347455
/* Don't repeat last error */
7435-
if ((int)mysql_errno(mysql) != last_errno)
7456+
if ((int)mysql_errno(mysql) != last_errno && !io_slave_killed(mi))
74367457
{
74377458
last_errno=mysql_errno(mysql);
74387459
suppress_warnings= 0;

0 commit comments

Comments
 (0)