mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Pause state improvements
This commit is contained in:
+10
-8
@@ -535,21 +535,23 @@ class Ha(object):
|
|||||||
|
|
||||||
def pause_action(self):
|
def pause_action(self):
|
||||||
if not self.state_handler.is_healthy():
|
if not self.state_handler.is_healthy():
|
||||||
return "Postgresql is not running"
|
return "Postgresql is not running. No action due to paused state"
|
||||||
|
|
||||||
if not (self.state_handler.is_leader() or self.state_handler.role == 'master'):
|
if not self.state_handler.is_leader():
|
||||||
return "I'm secondary"
|
if self.has_lock():
|
||||||
|
self.dcs.delete_leader()
|
||||||
|
return "I'm secondary. No action due to paused state"
|
||||||
|
|
||||||
if self.has_lock():
|
if self.has_lock():
|
||||||
if not self.update_lock():
|
if not self.update_lock():
|
||||||
# Either there is no connection to DCS or someone else acquired the lock
|
# Either there is no connection to DCS or someone else acquired the lock
|
||||||
logger.error('failed to update leader lock')
|
logger.error('failed to update leader lock')
|
||||||
self.load_cluster_from_dcs()
|
self.load_cluster_from_dcs()
|
||||||
else:
|
return "I'm the leader. Updating leader key"
|
||||||
|
elif self.cluster.is_unlocked():
|
||||||
if not self.acquire_lock():
|
if not self.acquire_lock():
|
||||||
raise Exception("Someone already acquired the lock")
|
return "Can't acquire the lock. No action due to paused state"
|
||||||
|
return "Cluster has no leader. Acquiring leader key"
|
||||||
return "I'm the leader"
|
|
||||||
|
|
||||||
def _run_cycle(self):
|
def _run_cycle(self):
|
||||||
try:
|
try:
|
||||||
@@ -568,7 +570,7 @@ class Ha(object):
|
|||||||
return self.handle_long_action_in_progress()
|
return self.handle_long_action_in_progress()
|
||||||
|
|
||||||
if self.is_paused():
|
if self.is_paused():
|
||||||
return self.pause_action() + ". No action due to paused state"
|
return self.pause_action()
|
||||||
|
|
||||||
# we've got here, so any 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:
|
||||||
|
|||||||
@@ -10,4 +10,3 @@ click>=4.1
|
|||||||
prettytable>=0.7
|
prettytable>=0.7
|
||||||
tzlocal
|
tzlocal
|
||||||
python-dateutil
|
python-dateutil
|
||||||
coverage
|
|
||||||
Reference in New Issue
Block a user