diff options
author | Nguyen Thanh Cong <ntcong1705@gmail.com> | 2020-11-20 09:07:01 +0700 |
---|---|---|
committer | Lingxian Kong <anlin.kong@gmail.com> | 2020-11-28 19:18:40 +0000 |
commit | d6b35435e0114c663ab481680371de45acd99c2e (patch) | |
tree | 62a722330faa75937c1006521bb5b352591fd88b | |
parent | bf3b2ca60985b63e40f1a419fb1ee10caeeffb51 (diff) | |
download | trove-d6b35435e0114c663ab481680371de45acd99c2e.tar.gz |
Use current slave_pos of slave to continue replicate
Because gtid is global and all operation are write to binlog, so incase
change to new master, we just use current slave_pos of slave, the slave
will just continue from the appropriate point in the new master's binlog.
Story: #2008376
Task: #41294
Change-Id: If129aef794c9b2e547c0a3acfc6855c3506cf930
(cherry picked from commit 8987244c407b7dcb13dec1f20d3cc8a2c82c4dcd)
-rw-r--r-- | trove/guestagent/strategies/replication/mariadb_gtid.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/trove/guestagent/strategies/replication/mariadb_gtid.py b/trove/guestagent/strategies/replication/mariadb_gtid.py index b95853bb..4909ee66 100644 --- a/trove/guestagent/strategies/replication/mariadb_gtid.py +++ b/trove/guestagent/strategies/replication/mariadb_gtid.py @@ -42,15 +42,11 @@ class MariaDBGTIDReplication(mysql_base.MysqlReplicationBase): logging_config = master_info['log_position'] last_gtid = '' - if 'gtid_pos' in logging_config: - # This will happen during master failover. - last_gtid = logging_config['gtid_pos'] - elif 'dataset' in master_info: + if 'dataset' in master_info: # This will happen when initial replication is set up. last_gtid = self.read_last_master_gtid(service) - - set_gtid_cmd = "SET GLOBAL gtid_slave_pos='%s';" % last_gtid - service.execute_sql(set_gtid_cmd) + set_gtid_cmd = "SET GLOBAL gtid_slave_pos='%s';" % last_gtid + service.execute_sql(set_gtid_cmd) change_master_cmd = ( "CHANGE MASTER TO " |