mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-09-02 01:29:36 +00:00
use TTLs with member listing to keep a current list of cluster members
This commit is contained in:
@@ -68,4 +68,6 @@ while True:
|
||||
if member != postgresql.name:
|
||||
postgresql.query("DO LANGUAGE plpgsql $$DECLARE somevar VARCHAR; BEGIN SELECT slot_name INTO somevar FROM pg_replication_slots WHERE slot_name = '%(slot)s' LIMIT 1; IF NOT FOUND THEN PERFORM pg_create_physical_replication_slot('%(slot)s'); END IF; END$$;" % {"slot": member})
|
||||
|
||||
etcd.touch_member(postgresql.name, postgresql.connection_string)
|
||||
|
||||
time.sleep(config["loop_wait"])
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ class Etcd:
|
||||
raise helpers.errors.CurrentLeaderError("Etcd is not responding properly")
|
||||
|
||||
def touch_member(self, member, connection_string):
|
||||
self.put_client_path("/members/%s" % member, {"value": connection_string})
|
||||
self.put_client_path("/members/%s" % member, {"value": connection_string, "ttl": self.ttl})
|
||||
|
||||
def take_leader(self, value):
|
||||
return self.put_client_path("/leader", {"value": value, "ttl": self.ttl}) == None
|
||||
|
||||
Reference in New Issue
Block a user