This commit is contained in:
Feike Steenbergen
2016-02-01 12:54:23 +01:00
parent d1e54174c7
commit 1d689d1e27
+5 -5
View File
@@ -25,7 +25,7 @@ class Ha:
def load_cluster_from_dcs(self): def load_cluster_from_dcs(self):
cluster = self.dcs.get_cluster() cluster = self.dcs.get_cluster()
# We want to keep the state of cluster when it was healhy # We want to keep the state of cluster when it was healthy
if not cluster.is_unlocked() or not self.old_cluster: if not cluster.is_unlocked() or not self.old_cluster:
self.old_cluster = cluster self.old_cluster = cluster
self.cluster = cluster self.cluster = cluster
@@ -296,7 +296,7 @@ class Ha:
return self.enforce_master_role('acquired session lock as a leader', return self.enforce_master_role('acquired session lock as a leader',
'promoted self to leader by acquiring session lock') 'promoted self to leader by acquiring session lock')
else: else:
return self.follow('demoted self due after trying and failing to obtain lock', return self.follow('demoted self after trying and failing to obtain lock',
'following new leader after trying and failing to obtain lock') 'following new leader after trying and failing to obtain lock')
else: else:
if self.patroni.nofailover: if self.patroni.nofailover:
@@ -402,7 +402,7 @@ class Ha:
if self._async_executor.busy: if self._async_executor.busy:
return self.handle_long_action_in_progress() return self.handle_long_action_in_progress()
# we've go here, so async action has finished. Check if we tried to recover and failed # we've got here, so any async action has finished. Check if we tried to recover and failed
if self.recovering: if self.recovering:
self.recovering = False self.recovering = False
msg = self.post_recover() msg = self.post_recover()
@@ -441,7 +441,7 @@ class Ha:
finally: finally:
# we might not have a valid PostgreSQL connection here if another thread # we might not have a valid PostgreSQL connection here if another thread
# stops PostgreSQL, therefore, we only reload replication slots if no # stops PostgreSQL, therefore, we only reload replication slots if no
# asyncrhonous processes are running (should be always the case for the master) # asynchronous processes are running (should be always the case for the master)
if not self._async_executor.busy: if not self._async_executor.busy:
self.state_handler.sync_replication_slots(self.cluster) self.state_handler.sync_replication_slots(self.cluster)
except DCSError: except DCSError:
@@ -450,7 +450,7 @@ class Ha:
self.demote(delete_leader=False) self.demote(delete_leader=False)
return 'demoted self because DCS is not accessible and i was a leader' return 'demoted self because DCS is not accessible and i was a leader'
except (psycopg2.Error, PostgresConnectionException): except (psycopg2.Error, PostgresConnectionException):
logger.exception('Error communicating with Postgresql. Will try again later') logger.exception('Error communicating with PostgreSQL. Will try again later')
def run_cycle(self): def run_cycle(self):
with self._async_executor: with self._async_executor: