MDEV-7107 Sporadic test failure in multi_source.multisource

Extend show_slave_status.inc to run SHOW ALL SLAVES STATUS and
SHOW SLAVE 'name' STATUS on demand, and make the test use
the include file instead of direct SHOW statements
This commit is contained in:
Elena Stepanova 2015-03-09 02:07:47 +02:00
parent 96784eb106
commit ec16d1b62f
3 changed files with 155 additions and 34 deletions

View File

@ -67,7 +67,21 @@
#
# --let $slave_sql_mode= NO_BACKSLASH_ESCAPES
#
# $all_slaves_status
# If set, use SHOW ALL SLAVES STATUS instead of SHOW SLAVE STATUS
# and get the column values from all rows. Example:
#
# --let $all_slaves_status= 1
#
# $slave_name
# If set, use SHOW SLAVE '<slave_name>' STATUS instead of SHOW SLAVE STATUS.
# The name must be quoted (can be a quoted empty string).
# Example:
#
# --let $slave_name= 'm1'
#
# Note: $all_slaves_status and $slave_name are mutually exclusive.
#
--let $_show_slave_status_items=$status_items
if (!$status_items)
@ -75,6 +89,21 @@ if (!$status_items)
--die Bug in test case: The mysqltest variable $status_items is not set.
}
--let $_show_query=SHOW SLAVE STATUS
if ($all_slaves_status)
{
if ($slave_name)
{
--die Bug in test case: Both $all_slaves_status and $slave_name are set.
}
--let $_show_query=SHOW ALL SLAVES STATUS
}
if ($slave_name)
{
--let $_show_query=SHOW SLAVE $slave_name STATUS
}
--let $_slave_sql_mode= NO_BACKSLASH_ESCAPES
if ($slave_sql_mode)
@ -86,18 +115,27 @@ if ($slave_sql_mode)
eval SET sql_mode= '$_slave_sql_mode';
--enable_query_log
--let $_slave_field_result_replace= /[\\\\]/\// $slave_field_result_replace
while ($_show_slave_status_items)
{
--let $_show_slave_status_name= `SELECT SUBSTRING_INDEX('$_show_slave_status_items', ',', 1)`
--let $_show_slave_status_items= `SELECT LTRIM(SUBSTRING('$_show_slave_status_items', LENGTH('$_show_slave_status_name') + 2))`
--replace_regex /\.[\\\/]master/master/
--let $_show_slave_status_value= query_get_value(SHOW SLAVE STATUS, $_show_slave_status_name, 1)
--let $_slave_field_result_replace= /[\\\\]/\// $slave_field_result_replace
--replace_regex $_slave_field_result_replace
--let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
--echo $_show_slave_status_name = '$_show_slave_status_value'
--let $num= 1
--let $_show_slave_status_value=
while ($_show_slave_status_value != 'No such row')
{
--replace_regex /\.[\\\/]master/master/
--let $_show_slave_status_value= query_get_value($_show_query, $_show_slave_status_name, $num)
if ($_show_slave_status_value != 'No such row')
{
--replace_regex $_slave_field_result_replace
--let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
--echo $_show_slave_status_name = '$_show_slave_status_value'
--inc $num
}
}
}

View File

@ -9,15 +9,36 @@ master_user='root';
start slave 'master1';
set default_master_connection = 'master1';
include/wait_for_slave_to_start.inc
show slave 'master1' status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos
Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No
show all slaves status;
Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 313 mysqld-relay-bin-master1.000002 601 master-bin.000001 Yes Yes 0 0 313 907 None 0 No 0 No 0 0 1 No 0 1073741824 7 0 60.000
#
# Checking SHOW SLAVE 'master1' STATUS
#
Master_Port = 'MYPORT_1'
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
Slave_IO_Running = 'Yes'
Slave_SQL_Running = 'Yes'
Last_Errno = '0'
Last_SQL_Errno = '0'
#
# Checking SHOW SLAVE STATUS
#
Master_Port = 'MYPORT_1'
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
Slave_IO_Running = 'Yes'
Slave_SQL_Running = 'Yes'
Last_Errno = '0'
Last_SQL_Errno = '0'
#
# Checking SHOW ALL SLAVES STATUS
#
Connection_name = 'master1'
Master_Port = 'MYPORT_1'
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
Slave_IO_Running = 'Yes'
Slave_SQL_Running = 'Yes'
Last_Errno = '0'
Last_SQL_Errno = '0'
Slave_heartbeat_period = '60.000'
#
drop database if exists db1;
create database db1;
use db1;
@ -74,10 +95,26 @@ master_host='127.0.0.1',
master_user='root';
start slave;
include/wait_for_slave_to_start.inc
show all slaves status;
Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 313 mysqld-relay-bin.000002 601 master-bin.000001 Yes Yes 0 0 313 899 None 0 No 0 No 0 0 2 No 0 1073741824 7 0 60.000 0-1-4
master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 988 mysqld-relay-bin-master1.000002 1276 master-bin.000001 Yes Yes 0 0 988 1582 None 0 No 0 No 0 0 1 No 0 1073741824 17 0 60.000 0-1-4
#
# Checking SHOW ALL SLAVES STATUS
#
Connection_name = ''
Connection_name = 'master1'
Master_Port = 'MYPORT_2'
Master_Port = 'MYPORT_1'
Relay_Log_File = 'mysqld-relay-bin.000002'
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
Slave_IO_Running = 'Yes'
Slave_IO_Running = 'Yes'
Slave_SQL_Running = 'Yes'
Slave_SQL_Running = 'Yes'
Last_Errno = '0'
Last_Errno = '0'
Last_SQL_Errno = '0'
Last_SQL_Errno = '0'
Slave_heartbeat_period = '60.000'
Slave_heartbeat_period = '60.000'
#
insert into t1 (f1) values ('three');
drop database if exists db2;
create database db2;
@ -104,10 +141,26 @@ Log_name File_size
master-bin.000002 367
insert into t1 (f1) values ('four');
create table db1.t3 (f1 int) engine=InnoDB;
show all slaves status;
Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 921 mysqld-relay-bin.000002 1209 master-bin.000001 Yes Yes 0 0 921 1507 None 0 No 0 No 0 0 2 No 0 1073741824 17 0 60.000 0-1-7
master1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000002 740 mysqld-relay-bin-master1.000004 1028 master-bin.000002 Yes Yes 0 0 740 1378 None 0 No 0 No 0 0 1 No 0 1073741824 37 0 60.000 0-1-7
#
# Checking SHOW ALL SLAVES STATUS
#
Connection_name = ''
Connection_name = 'master1'
Master_Port = 'MYPORT_2'
Master_Port = 'MYPORT_1'
Relay_Log_File = 'mysqld-relay-bin.000002'
Relay_Log_File = 'mysqld-relay-bin-master1.000004'
Slave_IO_Running = 'Yes'
Slave_IO_Running = 'Yes'
Slave_SQL_Running = 'Yes'
Slave_SQL_Running = 'Yes'
Last_Errno = '0'
Last_Errno = '0'
Last_SQL_Errno = '0'
Last_SQL_Errno = '0'
Slave_heartbeat_period = '60.000'
Slave_heartbeat_period = '60.000'
#
select * from db1.t1;
i f1
1 one

View File

@ -49,12 +49,28 @@ let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
--replace_result $SERVER_MYPORT_1 MYPORT_1
show slave 'master1' status;
--replace_result $SERVER_MYPORT_1 MYPORT_1
show slave status;
--replace_result $SERVER_MYPORT_1 MYPORT_1
show all slaves status;
--echo #
--echo # Checking SHOW SLAVE 'master1' STATUS
--echo #
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
--let $slave_name= 'master1'
--source include/show_slave_status.inc
--let $slave_name=
--echo #
--echo # Checking SHOW SLAVE STATUS
--echo #
--source include/show_slave_status.inc
--echo #
--echo # Checking SHOW ALL SLAVES STATUS
--echo #
--let $all_slaves_status= 1
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
--source include/show_slave_status.inc
--let $all_slaves_status=
--echo #
# Check that replication actually works
@ -144,8 +160,15 @@ let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2
show all slaves status;
--echo #
--echo # Checking SHOW ALL SLAVES STATUS
--echo #
--let $all_slaves_status= 1
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
--source include/show_slave_status.inc
--let $all_slaves_status=
--echo #
# Check that replication from two servers actually works
@ -214,8 +237,15 @@ let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2
show all slaves status;
--echo #
--echo # Checking SHOW ALL SLAVES STATUS
--echo #
--let $all_slaves_status= 1
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
--source include/show_slave_status.inc
--let $all_slaves_status=
--echo #
--sorted_result
select * from db1.t1;