Bug #81324 "rpl.rpl_start_stop_slave" fail sporadically on 5.5
Submitted: 5 May 2016 11:42 Modified: 5 May 2016 12:12
Reporter: Yura Sorokin (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version:5.5.49 OS:Any
Assigned to: CPU Architecture:Any

[5 May 2016 11:42] Yura Sorokin
Description:
"rpl.rpl_start_stop_slave" fail sporadically with the following output

**********************************************************************
rpl.rpl_start_stop_slave 'stmt' w2 [ fail ]
        Test ended at 2016-05-02 09:10:27

CURRENT_TEST: rpl.rpl_start_stop_slave
mysqltest: At line 30: query 'kill $connection_id' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

The result from queries just before the failure was:
include/master-slave.inc
[connection master]
set @time_before_kill := (select CURRENT_TIMESTAMP);
[Time before the query]
[Connection ID of the slave I/O thread found]
**********************************************************************

Tested on CentOS 7 x64 with MySQL Server 5.5.49.

How to repeat:
The probability of a failure is much higher when release binaries are used.
To reproduce, run the following

./mtr rpl.rpl_start_stop_slave rpl.rpl_start_stop_slave rpl.rpl_start_stop_slave rpl.rpl_start_stop_slave rpl.rpl_start_stop_slave rpl.rpl_start_stop_slave rpl.rpl_start_stop_slave rpl.rpl_start_stop_slave --repeat=32 --parallel=8

Suggested fix:
The problem seems to be in
--let $connection_id=`SELECT id FROM information_schema.processlist where state LIKE 'Waiting for master to send event'`

At this point slave connection may still be in 'Queueing master event to the relay log' state and therefore $connection_id can be empty.

To fix, we need to make sure that there is at least 1 connection with status 'Waiting for master to send event' before reading its id.
"wait_condition.inc" can be used for this.

***************************************************************************
let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state LIKE 'Waiting for master to send event';
--source include/wait_condition.inc
--let $connection_id=`SELECT id FROM information_schema.processlist where state LIKE 'Waiting for master to send event'`
***************************************************************************
[5 May 2016 12:12] MySQL Verification Team
Hello Yura Sorokin,

Thank you for the report.
Interestingly, I had to use debug binaries in order to see the reported issue.

Thanks,
Umesh