| 1 |
# In case master's gtid binlog state is divergent from the slave's gtid_slave_pos |
| 2 |
# slave may not be able to connect. |
| 3 |
# For instance when slave is more updated in some of domains, see |
| 4 |
# MDEV-12012 as example, the master's state may require adjustment. |
| 5 |
# In a specific case of an "old" divergent domain, that is there |
| 6 |
# won't be no more event groups from it generated, the states can be |
| 7 |
# made compatible with wiping the problematic domain away. After that slave |
| 8 |
# becomes connectable. |
| 9 |
# |
| 10 |
# Notice that the slave applied gtid state is not really required to |
| 11 |
# be similarly cleaned in order for replication to flow. |
| 12 |
# However this could lead to an expected error when the master |
| 13 |
# resumes binlogging of such domain which the test demonstrate. |
| 14 |
|
| 15 |
--source include/master-slave.inc |
| 16 |
|
| 17 |
--connection master |
| 18 |
# enforce the default domain_id binlogging explicitly |
| 19 |
SET @@SESSION.gtid_domain_id=0; |
| 20 |
CREATE TABLE t (a INT); |
| 21 |
--sync_slave_with_master |
| 22 |
|
| 23 |
--connection slave |
| 24 |
call mtr.add_suppression("connecting slave requested to start from.*which is not in the master's binlog"); |
| 25 |
|
| 26 |
--source include/stop_slave.inc |
| 27 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 28 |
|
| 29 |
--connection master |
| 30 |
# create extra gtid domains for binlog state |
| 31 |
--let $extra_domain_id=11 |
| 32 |
--let $extra_domain_server_id=111 |
| 33 |
--let $extra_gtid_seq_no=1 |
| 34 |
--eval SET @@SESSION.gtid_domain_id=$extra_domain_id |
| 35 |
--eval SET @@SESSION.server_id=$extra_domain_server_id |
| 36 |
--eval SET @@SESSION.gtid_seq_no=$extra_gtid_seq_no |
| 37 |
INSERT INTO t SET a=1; |
| 38 |
|
| 39 |
# |
| 40 |
# Set up the slave replication state as if slave knows more events from the extra |
| 41 |
# domain. |
| 42 |
# |
| 43 |
--connection slave |
| 44 |
SET @save.gtid_slave_pos=@@global.gtid_slave_pos; |
| 45 |
--eval SET @@global.gtid_slave_pos=concat(@@global.gtid_slave_pos, ",", $extra_domain_id, "-", $extra_domain_server_id, "-", $extra_gtid_seq_no + 1) |
| 46 |
|
| 47 |
# unsuccessful attempt to start slave |
| 48 |
START SLAVE IO_THREAD; |
| 49 |
--let $slave_io_errno=1236 |
| 50 |
--source include/wait_for_slave_io_error.inc |
| 51 |
|
| 52 |
--connection master |
| 53 |
# adjust the master binlog state |
| 54 |
FLUSH BINARY LOGS; |
| 55 |
--let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1) |
| 56 |
--let $purge_binlogs_to=$purge_to_binlog |
| 57 |
--source include/wait_for_purge.inc |
| 58 |
|
| 59 |
# with final removal of the extra domain |
| 60 |
--eval FLUSH BINARY LOGS DELETE_DOMAIN_ID=($extra_domain_id) |
| 61 |
SELECT @@global.gtid_binlog_pos, @@global.gtid_binlog_state; |
| 62 |
|
| 63 |
--connection slave |
| 64 |
SELECT @@global.gtid_slave_pos; |
| 65 |
# start the slave sucessfully |
| 66 |
--let rpl_debug=1 |
| 67 |
--source include/start_slave.inc |
| 68 |
--let rpl_debug=0 |
| 69 |
|
| 70 |
--connection master |
| 71 |
# but the following gtid from the *extra* domain will break replication |
| 72 |
INSERT INTO t SET a=1; |
| 73 |
|
| 74 |
# take note of the slave io thread error due to being dismissed |
| 75 |
# extra domain at connection to master which tried becoming active; |
| 76 |
# slave is to stop. |
| 77 |
--connection slave |
| 78 |
--let $errno=1236 |
| 79 |
--source include/wait_for_slave_io_error.inc |
| 80 |
|
| 81 |
# let's apply the very same medicine |
| 82 |
--connection master |
| 83 |
FLUSH BINARY LOGS; |
| 84 |
--let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1) |
| 85 |
--eval PURGE BINARY LOGS TO '$purge_to_binlog'; |
| 86 |
# with final removal of the extra domain |
| 87 |
--eval FLUSH BINARY LOGS DELETE_DOMAIN_ID=($extra_domain_id) |
| 88 |
|
| 89 |
--connection slave |
| 90 |
--source include/start_slave.inc |
| 91 |
|
| 92 |
# |
| 93 |
# cleanup |
| 94 |
# |
| 95 |
--connection master |
| 96 |
SET @@SESSION.gtid_domain_id=0; |
| 97 |
DROP TABLE t; |
| 98 |
|
| 99 |
sync_slave_with_master; |
| 100 |
|
| 101 |
--source include/rpl_end.inc |