From 267a81625f46ad9dd6d0f2ad6fe516c86820c9df Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Wed, 1 Apr 2015 15:16:35 -0400 Subject: [PATCH] Avoid unnecessary restart of replication master Eliminates the unnecessary restart of the master site in a replication set when a new slave is added to a previously existing master site. Also removed some dead code. Change-Id: Ia76cca5cb084270c45ce782b7cecc3e17f8402d8 Closes-bug: #1368419 --- trove/guestagent/datastore/mysql/service.py | 3 +++ trove/guestagent/strategies/replication/mysql_base.py | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/trove/guestagent/datastore/mysql/service.py b/trove/guestagent/datastore/mysql/service.py index 5bf278d6b0..d8c927137d 100644 --- a/trove/guestagent/datastore/mysql/service.py +++ b/trove/guestagent/datastore/mysql/service.py @@ -845,6 +845,9 @@ class MySqlApp(object): if os.path.exists(cnf_file): utils.execute_with_timeout("sudo", "rm", cnf_file) + def exists_replication_source_overrides(self): + return os.path.exists(MYCNF_REPLMASTER) + def write_replication_source_overrides(self, overrideValues): self._write_replication_overrides(overrideValues, MYCNF_REPLMASTER) diff --git a/trove/guestagent/strategies/replication/mysql_base.py b/trove/guestagent/strategies/replication/mysql_base.py index ab6237a3ec..23df0b773d 100644 --- a/trove/guestagent/strategies/replication/mysql_base.py +++ b/trove/guestagent/strategies/replication/mysql_base.py @@ -108,10 +108,9 @@ class MysqlReplicationBase(base.Replication): return snapshot_id, log_position def enable_as_master(self, service, master_config): - if not master_config: - master_config = self._get_master_config() - service.write_replication_source_overrides(master_config) - service.restart() + if not service.exists_replication_source_overrides(): + service.write_replication_source_overrides(master_config) + service.restart() @abc.abstractmethod def connect_to_master(self, service, snapshot):