mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-26 23:50:23 +00:00
Address review feedback
This commit is contained in:
+5
-5
@@ -147,7 +147,7 @@ class Ha(object):
|
||||
self._is_leader_lock = RLock()
|
||||
self._failsafe = Failsafe(patroni.dcs)
|
||||
self._was_paused = False
|
||||
self._promote_time = 0
|
||||
self._promote_timestamp = 0
|
||||
self._leader_timeline = None
|
||||
self.recovering = False
|
||||
self._async_response = CriticalTask()
|
||||
@@ -197,7 +197,7 @@ class Ha(object):
|
||||
with self._is_leader_lock:
|
||||
self._is_leader = time.time() + self.dcs.ttl if value else 0
|
||||
if not value:
|
||||
self._promote_time = 0
|
||||
self._promote_timestamp = 0
|
||||
|
||||
def load_cluster_from_dcs(self) -> None:
|
||||
cluster = self.dcs.get_cluster()
|
||||
@@ -754,10 +754,10 @@ class Ha(object):
|
||||
# be postponed for `loop_wait` seconds, to give a chance to some replicas to start streaming.
|
||||
# In opposite case the /sync key will end up without synchronous nodes.
|
||||
if self.state_handler.is_leader():
|
||||
if self._promote_time == 0 or time.time() - self._promote_time > self.dcs.loop_wait:
|
||||
if self._promote_timestamp == 0 or time.time() - self._promote_timestamp > self.dcs.loop_wait:
|
||||
self._process_quorum_replication()
|
||||
if self._promote_time == 0:
|
||||
self._promote_time = time.time()
|
||||
if self._promote_timestamp == 0:
|
||||
self._promote_timestamp = time.time()
|
||||
elif self.is_synchronous_mode():
|
||||
self._process_multisync_replication()
|
||||
else:
|
||||
|
||||
@@ -236,7 +236,7 @@ END;$$""")
|
||||
* ``pid`` - PID of the walsender process
|
||||
* ``member name`` - matches with the ``application_name```
|
||||
* ``sync_state`` - one of (``async``, ``potential``, ``quorum``, ``sync``)
|
||||
* ``LSN`` - ``write_lsn``, ``flush_lsn``, or ``replica_lsn``, depending on the value of
|
||||
* ``LSN`` - ``write_lsn``, ``flush_lsn``, or ``replica_lsn``, depending on the value of
|
||||
``synchronous_commit`` GUC
|
||||
* ``nofailover`` - whether the member has ``nofailover`` tag set
|
||||
"""
|
||||
|
||||
+1
-1
@@ -1516,7 +1516,7 @@ class TestHa(PostgresInit):
|
||||
self.assertEqual(mock_write_sync.call_args_list[0][1], {'version': None})
|
||||
self.assertEqual(mock_set_sync.call_count, 0)
|
||||
|
||||
self.ha._promote_time = 1
|
||||
self.ha._promote_timestamp = 1
|
||||
mock_write_sync = self.ha.dcs.write_sync_state = Mock(side_effect=[SyncState.empty(), None])
|
||||
# Test /sync key is attempted to set and succeed when missing or invalid
|
||||
with patch.object(SyncState, 'is_empty', Mock(side_effect=[True, False])):
|
||||
|
||||
Reference in New Issue
Block a user