Bug #85838 rpl_diff.inc in 5.7 does not compare data from different servers
Submitted: 6 Apr 2017 16:18 Modified: 18 Jul 2017 13:47
Reporter: Yura Sorokin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Tests: Replication Severity:S3 (Non-critical)
Version:5.7, 5.7.17, 8.0 OS:Any
Assigned to: CPU Architecture:Any

[6 Apr 2017 16:18] Yura Sorokin
Description:
'include/rpl_diff.inc' in 5.7 is broken.

Instead of retrieving data from different servers specified by $rpl_diff_servers or from all servers configured by 'rpl_init.inc', it always connects to the default server.

Therefore, including this file will always succeed and will never show actual data difference between servers.

Tested on 5.7.17

How to repeat:
Run the following MTR test case.

*********************************************
--source include/master-slave.inc

CREATE TABLE t1 (id INT);

--source include/sync_slave_sql_with_master.inc

--let $rpl_connection_name = slave
--source include/rpl_connection.inc
--source include/stop_slave.inc

--let $rpl_connection_name = master
--source include/rpl_connection.inc
INSERT INTO t1 VALUES (1), (2), (3);

--let $rpl_diff_statement = SELECT * FROM t1 ORDER BY id;
--let $rpl_skip_sync = 1
--source include/rpl_diff.inc

--let $rpl_connection_name = slave
--source include/rpl_connection.inc
--source include/start_slave.inc

--let $rpl_connection_name = master
--source include/rpl_connection.inc
--source include/sync_slave_sql_with_master.inc

--let $rpl_connection_name = master
--source include/rpl_connection.inc
DROP TABLE t1;
--source include/sync_slave_sql_with_master.inc

--source include/rpl_end.inc
*********************************************

As the slave was stopped when records were inserted into t1, master and slave should have had different content in t1. Nevertheless, 'rpl_diff.inc' succeeded.

Suggested fix:
Change
--exec $MYSQL $_rpl_diff_database < $_rpl_diff_statement_file > $_rpl_diff_file

back to
--exec $MYSQL --defaults-group-suffix=.$_rpl_diff_server_i $_rpl_diff_database < $_rpl_diff_statement_file > $_rpl_diff_file

in 'include/rpl_diff.inc'
[6 Apr 2017 16:29] Yura Sorokin
This is a 5.7-only bug. Both 5.5. and 5.6 have proper '--defaults-group-suffix=.$_rpl_diff_server_i' argument.
[6 Apr 2017 16:40] Yura Sorokin
This include also does not remove generated $_rpl_diff_statement_file file at the end.
[7 Apr 2017 12:50] Umesh Shastry
Hello Yura,

Thank you for the report and test case.

Thanks,
Umesh
[11 Apr 2017 12:12] Yura Sorokin
Also affects 8.0
[11 Apr 2017 12:13] Yura Sorokin
Patch for 5.5 and 5.6

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: rpl_diff_55_56.patch (application/octet-stream, text), 423 bytes.

[11 Apr 2017 12:14] Yura Sorokin
Patch for 5.7 and 8.0

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: rpl_diff_57_80.patch (application/octet-stream, text), 837 bytes.

[18 Jul 2017 13:47] Margaret Fisher
Posted by developer:
 
Changelog entry added for 5.7 and 8.0:
The rpl_diff.inc test case file did not find the data difference between servers. Thanks to Yura Sorokin for the patch.
[19 Jul 2017 8:43] Laurynas Biveinis
Which 5.7 and 8.0 minor versions the fix is in?