mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Fix bug with slot for former leader not retained on failover (#3261)
the problem existed because _build_retain_slots() method was falsely relying on members being present in DCS, while on failover the member key for the former leader is expiring exactly at the same time.
This commit is contained in:
@@ -81,4 +81,6 @@ Feature: permanent slots
|
||||
When I start postgres-0
|
||||
Then postgres-0 role is the replica after 20 seconds
|
||||
And physical replication slot named postgres_1 on postgres-0 has no xmin value after 10 seconds
|
||||
And physical replication slot named postgres_2 on postgres-0 has no xmin value after 10 seconds
|
||||
# postgres_2 and postgres_3 slots are retained, but postgres_2 will still have xmin value :(
|
||||
And postgres-0 has a physical replication slot named postgres_2 after 10 seconds
|
||||
And postgres-0 has a physical replication slot named postgres_3 after 10 seconds
|
||||
|
||||
@@ -99,8 +99,8 @@ def has_physical_replication_slot(context, pg_name, slot_name, time_limit):
|
||||
def physical_slot_no_xmin(context, pg_name, slot_name, time_limit):
|
||||
time_limit *= context.timeout_multiplier
|
||||
max_time = time.time() + int(time_limit)
|
||||
query = "SELECT xmin FROM pg_catalog.pg_replication_slots WHERE slot_type = 'physical'"
|
||||
f" AND slot_name = '{slot_name}'"
|
||||
query = "SELECT xmin FROM pg_catalog.pg_replication_slots WHERE slot_type = 'physical'" +\
|
||||
f" AND slot_name = '{slot_name}'"
|
||||
exists = False
|
||||
while time.time() < max_time:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user