Bug #86222 GR Member stop must all asynchronous channels that are feeding data into it
Submitted: 8 May 2017 17:07 Modified: 15 Sep 2017 10:55
Reporter: Nuno Carvalho Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Group Replication Severity:S3 (Non-critical)
Version:5.7.17 OS:Any
Assigned to: CPU Architecture:Any

[8 May 2017 17:07] Nuno Carvalho
Description:
If a member that has asynchronous channels feeding data into it - either on multi-primary deploy or the primary on single-primary deploy - does stop, all asynchronous channels must be stopped to avoid that changes are made locally (not replicated to the group).

Even when super_read_only it is set on STOP GROUP_REPLICATION, that will not affect already running asynchronous which can still do changes.

How to repeat:
Please run the following test (also on attachment):

--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420002
--source ../inc/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--source ../inc/group_replication.inc

--echo
--echo ############################################################
--echo #  1. Setup Group Replication on server 1.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source ../inc/start_and_bootstrap_group_replication.inc

--echo
--echo ############################################################
--echo #  2. Setup a asynchronous replication connection from server 2
--echo #     into group (server 1)
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--replace_result $SERVER_MYPORT_2 SERVER_2_PORT
--eval CHANGE MASTER TO MASTER_HOST="127.0.0.1", MASTER_USER="root", MASTER_PASSWORD="", MASTER_PORT=$SERVER_MYPORT_2, MASTER_AUTO_POSITION=1
--source include/start_slave.inc

--echo
--echo ############################################################
--echo #  3. Execute some transactions on server 2.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0);

--echo
--echo ############################################################
--echo #  4. Wait until transactions executed on server 2 are applied
--echo #     on group.
--let $sync_slave_connection= server1
--source include/sync_slave_sql_with_master.inc

--echo
--echo ############################################################
--echo #  5. Stop group.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--echo
--echo ############################################################
--echo #  6. Execute data on server 2 and ensure it is not accepted on server 1.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
INSERT INTO t1 VALUES (1);

--echo
--echo ############################################################
--echo #  6. Validate data on server 1.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
# FIXME remove sleep
--sleep 3
--let $assert_text= 'There is no value 1 in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 0
--source include/assert.inc

--exit
# FIXME more validations

Suggested fix:
Stop all asynchronous channels on STOP GROUP_REPLICATION.
[15 Sep 2017 10:55] David Moss
Posted by developer:
 
Thank you for your feedback, this has been fixed in upcoming versions and the following was added to the 5.7.20 / 8.0.4 changelog:
When a primary member, for example the primary in single-primary group or in a multi-primary group, which also had asynchronous replication channels feeding data into it was stopped, the asynchronous channels would continue applying changes.  Although super_read_only was being set when STOP GROUP_REPLICATION was issued, this did not stop already running asynchronous replication channels. This meant that changes could be made locally on the member, and that the asynchronous replication channels had to be stopped manually. Now when Group Replication stops, either due to an error or when STOP GROUP_REPLICATION; is issued, all asynchronous replication channels are stopped.