Set _need_rewind to True if the node was previously known as a master

This commit is contained in:
Alexander Kukushkin
2016-09-01 11:29:45 +02:00
parent db9b62b7ed
commit f082ecf60b
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -400,6 +400,7 @@ class Ha(object):
'following new leader after trying and failing to obtain lock')
else:
# when we are doing manual failover there is no guaranty that new leader is ahead of any other node
# node tagged as nofailover can be ahead of the new leader either, but it is always excluded from elections
need_rewind = bool(self.cluster.failover) or self.patroni.nofailover
if need_rewind:
sleep(2) # Give a time to somebody to take the leader lock
+2
View File
@@ -774,6 +774,8 @@ class Postgresql(object):
self._need_rewind = False
if self.is_running():
return
elif change_role:
self._need_rewind = True
self._need_rewind &= bool(leader and leader.conn_url) and self.can_rewind