From 17252979983fe1a6f574ba71f81155108717d388 Mon Sep 17 00:00:00 2001 From: munakoiso Date: Fri, 15 Nov 2024 19:09:15 +0500 Subject: [PATCH] better slots on dead iter (#53) --- src/__init__.py | 2 +- src/main.py | 1 + tests/features/cascade.feature | 1 + tests/features/kill_primary.feature | 1 + tests/features/slot.feature | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/__init__.py b/src/__init__.py index 9952506..d816b7f 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -77,7 +77,7 @@ def read_config(filename=None, options=None): 'certfile': None, 'ca_cert': None, 'verify_certs': 'no', - 'drop_slot_countdown': 10, + 'drop_slot_countdown': 300, 'replication_slots_polling': None, 'max_allowed_switchover_lag_ms': 60000, }, diff --git a/src/main.py b/src/main.py index 52e87dd..16668c0 100644 --- a/src/main.py +++ b/src/main.py @@ -878,6 +878,7 @@ def dead_iter(self, db_state, zk_state, is_actually_dead): holder = self.zk.get_current_lock_holder() if holder and holder != helpers.get_hostname(): if role == 'replica' and holder == last_primary: + self._acquire_replication_source_slot_lock(last_primary) logging.info('Seems that primary has not changed but PostgreSQL is dead. Starting it.') return self.db.start_postgresql() diff --git a/tests/features/cascade.feature b/tests/features/cascade.feature index 7836d04..d097c89 100644 --- a/tests/features/cascade.feature +++ b/tests/features/cascade.feature @@ -364,6 +364,7 @@ Feature: Check not HA hosts priority: 0 use_replication_slots: 'yes' quorum_commit: 'yes' + drop_slot_countdown: 10 primary: change_replication_type: 'yes' primary_switch_checks: 1 diff --git a/tests/features/kill_primary.feature b/tests/features/kill_primary.feature index c110f56..4fbc847 100644 --- a/tests/features/kill_primary.feature +++ b/tests/features/kill_primary.feature @@ -303,6 +303,7 @@ Feature: Destroy primary in various scenarios priority: 0 use_replication_slots: 'yes' quorum_commit: 'yes' + drop_slot_countdown: 10 primary: change_replication_type: 'yes' primary_switch_checks: 1 diff --git a/tests/features/slot.feature b/tests/features/slot.feature index ed1f8ff..a880a48 100644 --- a/tests/features/slot.feature +++ b/tests/features/slot.feature @@ -8,6 +8,7 @@ Feature: Replication slots global: priority: 0 use_replication_slots: 'yes' + drop_slot_countdown: 10 primary: change_replication_type: 'no' primary_switch_checks: 1