Skip to content

Commit ec16d1b

Browse files
committed
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
1 parent 96784eb commit ec16d1b

File tree

3 files changed

+155
-34
lines changed

3 files changed

+155
-34
lines changed

mysql-test/include/show_slave_status.inc

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,43 @@
6767
#
6868
# --let $slave_sql_mode= NO_BACKSLASH_ESCAPES
6969
#
70-
70+
# $all_slaves_status
71+
# If set, use SHOW ALL SLAVES STATUS instead of SHOW SLAVE STATUS
72+
# and get the column values from all rows. Example:
73+
#
74+
# --let $all_slaves_status= 1
75+
#
76+
# $slave_name
77+
# If set, use SHOW SLAVE '<slave_name>' STATUS instead of SHOW SLAVE STATUS.
78+
# The name must be quoted (can be a quoted empty string).
79+
# Example:
80+
#
81+
# --let $slave_name= 'm1'
82+
#
83+
# Note: $all_slaves_status and $slave_name are mutually exclusive.
84+
#
7185

7286
--let $_show_slave_status_items=$status_items
7387
if (!$status_items)
7488
{
7589
--die Bug in test case: The mysqltest variable $status_items is not set.
7690
}
7791

92+
--let $_show_query=SHOW SLAVE STATUS
93+
94+
if ($all_slaves_status)
95+
{
96+
if ($slave_name)
97+
{
98+
--die Bug in test case: Both $all_slaves_status and $slave_name are set.
99+
}
100+
--let $_show_query=SHOW ALL SLAVES STATUS
101+
}
102+
if ($slave_name)
103+
{
104+
--let $_show_query=SHOW SLAVE $slave_name STATUS
105+
}
106+
78107

79108
--let $_slave_sql_mode= NO_BACKSLASH_ESCAPES
80109
if ($slave_sql_mode)
@@ -86,18 +115,27 @@ if ($slave_sql_mode)
86115
eval SET sql_mode= '$_slave_sql_mode';
87116
--enable_query_log
88117

118+
--let $_slave_field_result_replace= /[\\\\]/\// $slave_field_result_replace
89119

90120
while ($_show_slave_status_items)
91121
{
92122
--let $_show_slave_status_name= `SELECT SUBSTRING_INDEX('$_show_slave_status_items', ',', 1)`
93123
--let $_show_slave_status_items= `SELECT LTRIM(SUBSTRING('$_show_slave_status_items', LENGTH('$_show_slave_status_name') + 2))`
94124

95-
--replace_regex /\.[\\\/]master/master/
96-
--let $_show_slave_status_value= query_get_value(SHOW SLAVE STATUS, $_show_slave_status_name, 1)
97-
--let $_slave_field_result_replace= /[\\\\]/\// $slave_field_result_replace
98-
--replace_regex $_slave_field_result_replace
99-
--let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
100-
--echo $_show_slave_status_name = '$_show_slave_status_value'
125+
--let $num= 1
126+
--let $_show_slave_status_value=
127+
while ($_show_slave_status_value != 'No such row')
128+
{
129+
--replace_regex /\.[\\\/]master/master/
130+
--let $_show_slave_status_value= query_get_value($_show_query, $_show_slave_status_name, $num)
131+
if ($_show_slave_status_value != 'No such row')
132+
{
133+
--replace_regex $_slave_field_result_replace
134+
--let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
135+
--echo $_show_slave_status_name = '$_show_slave_status_value'
136+
--inc $num
137+
}
138+
}
101139
}
102140

103141

mysql-test/suite/multi_source/multisource.result

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,36 @@ master_user='root';
99
start slave 'master1';
1010
set default_master_connection = 'master1';
1111
include/wait_for_slave_to_start.inc
12-
show slave 'master1' status;
13-
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
14-
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
15-
show slave status;
16-
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
17-
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
18-
show all slaves status;
19-
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
20-
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
12+
#
13+
# Checking SHOW SLAVE 'master1' STATUS
14+
#
15+
Master_Port = 'MYPORT_1'
16+
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
17+
Slave_IO_Running = 'Yes'
18+
Slave_SQL_Running = 'Yes'
19+
Last_Errno = '0'
20+
Last_SQL_Errno = '0'
21+
#
22+
# Checking SHOW SLAVE STATUS
23+
#
24+
Master_Port = 'MYPORT_1'
25+
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
26+
Slave_IO_Running = 'Yes'
27+
Slave_SQL_Running = 'Yes'
28+
Last_Errno = '0'
29+
Last_SQL_Errno = '0'
30+
#
31+
# Checking SHOW ALL SLAVES STATUS
32+
#
33+
Connection_name = 'master1'
34+
Master_Port = 'MYPORT_1'
35+
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
36+
Slave_IO_Running = 'Yes'
37+
Slave_SQL_Running = 'Yes'
38+
Last_Errno = '0'
39+
Last_SQL_Errno = '0'
40+
Slave_heartbeat_period = '60.000'
41+
#
2142
drop database if exists db1;
2243
create database db1;
2344
use db1;
@@ -74,10 +95,26 @@ master_host='127.0.0.1',
7495
master_user='root';
7596
start slave;
7697
include/wait_for_slave_to_start.inc
77-
show all slaves status;
78-
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
79-
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
80-
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
98+
#
99+
# Checking SHOW ALL SLAVES STATUS
100+
#
101+
Connection_name = ''
102+
Connection_name = 'master1'
103+
Master_Port = 'MYPORT_2'
104+
Master_Port = 'MYPORT_1'
105+
Relay_Log_File = 'mysqld-relay-bin.000002'
106+
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
107+
Slave_IO_Running = 'Yes'
108+
Slave_IO_Running = 'Yes'
109+
Slave_SQL_Running = 'Yes'
110+
Slave_SQL_Running = 'Yes'
111+
Last_Errno = '0'
112+
Last_Errno = '0'
113+
Last_SQL_Errno = '0'
114+
Last_SQL_Errno = '0'
115+
Slave_heartbeat_period = '60.000'
116+
Slave_heartbeat_period = '60.000'
117+
#
81118
insert into t1 (f1) values ('three');
82119
drop database if exists db2;
83120
create database db2;
@@ -104,10 +141,26 @@ Log_name File_size
104141
master-bin.000002 367
105142
insert into t1 (f1) values ('four');
106143
create table db1.t3 (f1 int) engine=InnoDB;
107-
show all slaves status;
108-
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
109-
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
110-
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
144+
#
145+
# Checking SHOW ALL SLAVES STATUS
146+
#
147+
Connection_name = ''
148+
Connection_name = 'master1'
149+
Master_Port = 'MYPORT_2'
150+
Master_Port = 'MYPORT_1'
151+
Relay_Log_File = 'mysqld-relay-bin.000002'
152+
Relay_Log_File = 'mysqld-relay-bin-master1.000004'
153+
Slave_IO_Running = 'Yes'
154+
Slave_IO_Running = 'Yes'
155+
Slave_SQL_Running = 'Yes'
156+
Slave_SQL_Running = 'Yes'
157+
Last_Errno = '0'
158+
Last_Errno = '0'
159+
Last_SQL_Errno = '0'
160+
Last_SQL_Errno = '0'
161+
Slave_heartbeat_period = '60.000'
162+
Slave_heartbeat_period = '60.000'
163+
#
111164
select * from db1.t1;
112165
i f1
113166
1 one

mysql-test/suite/multi_source/multisource.test

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,28 @@ let $field= Slave_IO_State;
4949
let $condition= = 'Waiting for master to send event';
5050
--source include/wait_show_condition.inc
5151

52-
--replace_result $SERVER_MYPORT_1 MYPORT_1
53-
show slave 'master1' status;
54-
--replace_result $SERVER_MYPORT_1 MYPORT_1
55-
show slave status;
56-
--replace_result $SERVER_MYPORT_1 MYPORT_1
57-
show all slaves status;
52+
--echo #
53+
--echo # Checking SHOW SLAVE 'master1' STATUS
54+
--echo #
55+
--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
56+
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
57+
--let $slave_name= 'master1'
58+
--source include/show_slave_status.inc
59+
--let $slave_name=
60+
61+
--echo #
62+
--echo # Checking SHOW SLAVE STATUS
63+
--echo #
64+
--source include/show_slave_status.inc
65+
66+
--echo #
67+
--echo # Checking SHOW ALL SLAVES STATUS
68+
--echo #
69+
--let $all_slaves_status= 1
70+
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
71+
--source include/show_slave_status.inc
72+
--let $all_slaves_status=
73+
--echo #
5874

5975

6076
# Check that replication actually works
@@ -144,8 +160,15 @@ let $field= Slave_IO_State;
144160
let $condition= = 'Waiting for master to send event';
145161
--source include/wait_show_condition.inc
146162

147-
--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2
148-
show all slaves status;
163+
--echo #
164+
--echo # Checking SHOW ALL SLAVES STATUS
165+
--echo #
166+
--let $all_slaves_status= 1
167+
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
168+
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
169+
--source include/show_slave_status.inc
170+
--let $all_slaves_status=
171+
--echo #
149172

150173
# Check that replication from two servers actually works
151174

@@ -214,8 +237,15 @@ let $field= Slave_IO_State;
214237
let $condition= = 'Waiting for master to send event';
215238
--source include/wait_show_condition.inc
216239

217-
--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2
218-
show all slaves status;
240+
--echo #
241+
--echo # Checking SHOW ALL SLAVES STATUS
242+
--echo #
243+
--let $all_slaves_status= 1
244+
--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
245+
--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
246+
--source include/show_slave_status.inc
247+
--let $all_slaves_status=
248+
--echo #
219249

220250
--sorted_result
221251
select * from db1.t1;

0 commit comments

Comments
 (0)