mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-09-01 17:19:31 +00:00
Address code review feedback
This commit is contained in:
@@ -234,10 +234,10 @@ class _ReplicaList(List[_Replica]):
|
||||
row['sync_state'], row[sort_col], bool(member.nofailover)))
|
||||
|
||||
# Prefer replicas that are in state ``sync`` and with higher values of ``write``/``flush``/``replay`` LSN.
|
||||
self.sort(key=lambda r: (r.nofailover, r.sync_state, r.lsn), reverse=True)
|
||||
self.sort(key=lambda r: (r.sync_state, r.lsn), reverse=True)
|
||||
|
||||
# When checking ``maximum_lag_on_syncnode`` we want to compare with the most
|
||||
# up-to-date replica or with cluster LSN if there is only one replica.
|
||||
# up-to-date replica otherwise with cluster LSN if there is only one replica.
|
||||
self.max_lsn = max(self, key=lambda x: x.lsn).lsn if len(self) > 1 else postgresql.last_operation()
|
||||
|
||||
|
||||
|
||||
+8
-5
@@ -36,17 +36,20 @@ class QuorumStateResolver(object):
|
||||
To keep the invariant the rule to follow is that when increasing ``numsync`` or ``quorum``, we need to perform the
|
||||
increasing operation first. When decreasing either, the decreasing operation needs to be performed later.
|
||||
|
||||
Order of adding or removing nodes from ``sync`` and ``voters`` depends on the state of ``synchronous_standby_names``:
|
||||
Order of adding or removing nodes from ``sync`` and ``voters`` depends on the state of
|
||||
``synchronous_standby_names``.
|
||||
When adding new nodes:
|
||||
if ``sync`` (``synchronous_standby_names``) is empty:
|
||||
add new nodes first to ``sync`` and then to ``voters`` when ``numsync_confirmed`` > ``0``
|
||||
add new nodes first to ``sync`` and then to ``voters`` when ``numsync_confirmed`` > ``0``.
|
||||
else:
|
||||
add new nodes first to ``voters`` and then to ``sync``
|
||||
add new nodes first to ``voters`` and then to ``sync``.
|
||||
When removing nodes:
|
||||
if ``sync`` (``synchronous_standby_names``) will become empty after removal:
|
||||
first remove nodes from ``voters`` and then from ``sync``
|
||||
first remove nodes from ``voters`` and then from ``sync``.
|
||||
else:
|
||||
first remove nodes from ``sync`` and then from ``voters``. Make ``voters`` empty if ``numsync_confirmed`` == ``0``"""
|
||||
first remove nodes from ``sync`` and then from ``voters``.
|
||||
Make ``voters`` empty if ``numsync_confirmed`` == ``0``.
|
||||
"""
|
||||
|
||||
def __init__(self, leader: str, quorum: int, voters: Collection[str],
|
||||
numsync: int, sync: Collection[str], numsync_confirmed: int,
|
||||
|
||||
+1
-1
@@ -753,7 +753,7 @@ def cluster_as_json(cluster: 'Cluster', global_config: Optional['GlobalConfig']
|
||||
|
||||
* ``members``: list of members in the cluster. Each value is a :class:`dict` that may have the following keys:
|
||||
* ``name``: the name of the host (unique in the cluster). The ``members`` list is sorted by this key;
|
||||
* ``role``: ``leader``, ``standby_leader``, ``sync_standby``, or ``replica``;
|
||||
* ``role``: ``leader``, ``standby_leader``, ``quorum_standby``, ``sync_standby``, or ``replica``;
|
||||
* ``state``: ``stopping``, ``stopped``, ``stop failed``, ``crashed``, ``running``, ``starting``,
|
||||
``start failed``, ``restarting``, ``restart failed``, ``initializing new cluster``, ``initdb failed``,
|
||||
``running custom bootstrap script``, ``custom bootstrap failed``, or ``creating replica``;
|
||||
|
||||
Reference in New Issue
Block a user