Skip to content

Commit

Permalink
Fixed bug in semi_sync replication tests.
Browse files Browse the repository at this point in the history
The problem was that wait_for_slave_io_to_start reported that the io thread
was ready, when it was still initializing. This caused test suite to
continue too early, for example before the semi sync plugin was properly
enabled.

Fixed by introducing a new internal stage: "Preparing". Slave_IO_Running is
now set to "Yes" only when all initializing is done and the IO thread is
ready to read things from the master.

The only test affected by this change is rpl_flsh_tbls, which got stuck in
the preparing phase while trying to read the GTID position from a table.
Fixed by having this test waiting for Preparing instead of Yes.
  • Loading branch information
montywi committed Jan 3, 2016
1 parent 661a6d8 commit 8fcc0bf
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 14 deletions.
8 changes: 7 additions & 1 deletion mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ drop table t1;
connection slave;
flush tables with read lock;
start slave;
source include/wait_for_slave_to_start.inc;

# The IO thread will not be able to read the GTID because of flush tables
let $slave_param= Slave_IO_Running;
let $slave_param_value= Preparing;
source include/wait_for_slave_param.inc;

--source include/wait_for_slave_sql_to_start.inc
--error 1192
stop slave;

Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ include/wait_for_slave_to_stop.inc
drop table t1;
flush tables with read lock;
start slave;
include/wait_for_slave_to_start.inc
include/wait_for_slave_param.inc [Slave_IO_Running]
include/wait_for_slave_sql_to_start.inc
stop slave;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables;
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/rpl/r/rpl_semi_sync_uninstall_plugin.result
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ DROP TABLE t1;
[connection slave]
include/install_semisync.inc
[connection slave]
show global status like "Slave%_running";
Variable_name Value
Slave_running ON
Slaves_running 1
UNINSTALL PLUGIN rpl_semi_sync_slave;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
plugin_name plugin_status
rpl_semi_sync_slave DELETED
[connection master]
show global status like "Slave%_connect%";
Variable_name Value
Slave_connections 2
Slaves_connected 1
UNINSTALL PLUGIN rpl_semi_sync_master;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/rpl/r/rpl_stm_flsh_tbls.result
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ include/wait_for_slave_to_stop.inc
drop table t1;
flush tables with read lock;
start slave;
include/wait_for_slave_to_start.inc
include/wait_for_slave_param.inc [Slave_IO_Running]
include/wait_for_slave_sql_to_start.inc
stop slave;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables;
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/suite/rpl/t/rpl_semi_sync_uninstall_plugin.test
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ DROP TABLE t1;
# possible at this state
--connection slave
--echo [connection slave]
show global status like "Slave%_running";

UNINSTALL PLUGIN rpl_semi_sync_slave;
select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';

# Step 2.3: Check that rpl_semi_sync_master uninstallation on Master is not
# possible at this state
--connection master
--echo [connection master]

# The following is to catch errors if the next uninstall plugin would succeed
show global status like "Slave%_connect%";

UNINSTALL PLUGIN rpl_semi_sync_master;
select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';

Expand Down
4 changes: 2 additions & 2 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7287,8 +7287,8 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE);
if (mi)
tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_CONNECT &&
mi->rli.slave_running);
tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_READING &&
mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN);
}
mysql_mutex_unlock(&LOCK_active_mi);
if (mi)
Expand Down
2 changes: 1 addition & 1 deletion sql/rpl_mi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ bool Master_info_index::start_all_slaves(THD *thd)
Try to start all slaves that are configured (host is defined)
and are not already running
*/
if ((mi->slave_running != MYSQL_SLAVE_RUN_CONNECT ||
if ((mi->slave_running == MYSQL_SLAVE_NOT_RUN ||
!mi->rli.slave_running) && *mi->host)
{
if ((error= start_slave(thd, mi, 1)))
Expand Down
8 changes: 4 additions & 4 deletions sql/slave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,8 @@ static bool send_show_master_info_header(THD *thd, bool full,
DBUG_RETURN(FALSE);
}

/* Text for Slave_IO_Running */
static const char *slave_running[]= { "No", "Connecting", "Preparing", "Yes" };

static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
String *gtid_pos)
Expand Down Expand Up @@ -2668,9 +2670,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
&my_charset_bin);
protocol->store((ulonglong) mi->rli.group_relay_log_pos);
protocol->store(mi->rli.group_master_log_name, &my_charset_bin);
protocol->store(mi->slave_running == MYSQL_SLAVE_RUN_CONNECT ?
"Yes" : (mi->slave_running == MYSQL_SLAVE_RUN_NOT_CONNECT ?
"Connecting" : "No"), &my_charset_bin);
protocol->store(slave_running[mi->slave_running], &my_charset_bin);
protocol->store(mi->rli.slave_running ? "Yes":"No", &my_charset_bin);
protocol->store(rpl_filter->get_do_db());
protocol->store(rpl_filter->get_ignore_db());
Expand Down Expand Up @@ -2713,7 +2713,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
Seconds_Behind_Master: if SQL thread is running and I/O thread is
connected, we can compute it otherwise show NULL (i.e. unknown).
*/
if ((mi->slave_running == MYSQL_SLAVE_RUN_CONNECT) &&
if ((mi->slave_running == MYSQL_SLAVE_RUN_READING) &&
mi->rli.slave_running)
{
long time_diff;
Expand Down
9 changes: 5 additions & 4 deletions sql/slave.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ extern my_bool opt_replicate_annotate_row_events;
extern ulonglong relay_log_space_limit;

/*
3 possible values for Master_info::slave_running and
4 possible values for Master_info::slave_running and
Relay_log_info::slave_running.
The values 0,1,2 are very important: to keep the diff small, I didn't
substitute places where we use 0/1 with the newly defined symbols. So don't change
these values.
The values 0,1,2,3 are very important: to keep the diff small, I didn't
substitute places where we use 0/1 with the newly defined symbols.
So don't change these values.
The same way, code is assuming that in Relay_log_info we use only values
0/1.
I started with using an enum, but
Expand All @@ -145,6 +145,7 @@ extern ulonglong relay_log_space_limit;
#define MYSQL_SLAVE_NOT_RUN 0
#define MYSQL_SLAVE_RUN_NOT_CONNECT 1
#define MYSQL_SLAVE_RUN_CONNECT 2
#define MYSQL_SLAVE_RUN_READING 3

#define RPL_LOG_NAME (rli->group_master_log_name[0] ? rli->group_master_log_name :\
"FIRST")
Expand Down

0 comments on commit 8fcc0bf

Please sign in to comment.