mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Make the cached role coherrent with the actual one.
When observing the leader running a master role, set the cached role stored in the state_handler to master as well. Failure to do so resulted in the manually promoted node to continue running with a cached 'replica' role. This led to the failure to create replication slots for the new replicas. We could do it conditionally, but both reading and writing the role require the same lock, and the unconditional approach makes the unit tests simpler.
This commit is contained in:
@@ -158,6 +158,9 @@ class Ha(object):
|
||||
|
||||
def enforce_master_role(self, message, promote_message):
|
||||
if self.state_handler.is_leader() or self.state_handler.role == 'master':
|
||||
# Inform the state handler about its master role.
|
||||
# It may be unaware of it if postgres is promoted manually.
|
||||
self.state_handler.set_role('master')
|
||||
return message
|
||||
else:
|
||||
self.state_handler.promote()
|
||||
|
||||
Reference in New Issue
Block a user