Address review feedback

This commit is contained in:
Alexander Kukushkin
2023-08-24 12:11:55 +02:00
parent 79b409847d
commit 3a602f099e
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -159,8 +159,8 @@ class _SyncState(NamedTuple):
:ivar sync_type: possible values: ``off``, ``priority``, ``quorum``
:ivar numsync: how many nodes are required to be synchronous (according to ``synchronous_standby_names``).
Is ``0`` if ``synchronous_standby_names`` value is invalid or contains ``*``.
:ivar numsync_confirmed: how many nodes are known to be synchronous according to the ``pg_stat_replication``
view. Only nodes that caught up with the :attr:`SyncHandler._primary_flush_lsn` are counted.
:ivar numsync_confirmed: how many nodes are known to be synchronous according to the ``pg_stat_replication`` view.
Only nodes that caught up with the :attr:`SyncHandler._primary_flush_lsn` are counted.
:ivar sync: collection of synchronous node names. In case of quorum commit all nodes listed
in ``synchronous_standby_names``, otherwise nodes that are confirmed to be synchronous according
to the ``pg_stat_replication`` view.
+6 -3
View File
@@ -1,8 +1,10 @@
"""Implement state machine to manage ``synchronous_standby_names`` GUC and ``/sync`` key in DCS."""
import logging
from typing import Collection, Iterator, NamedTuple, Optional
from .collections import CaseInsensitiveSet
from .exceptions import PatroniException
logger = logging.getLogger(__name__)
@@ -31,12 +33,12 @@ class Transition(NamedTuple):
names: CaseInsensitiveSet
class QuorumError(Exception):
class QuorumError(PatroniException):
"""Exception indicating that the quorum state is broken."""
class QuorumStateResolver(object):
"""Calculates a list of state transition tuples of the form `('sync'/'quorum'/'restart',leader,number,set_of_names)`
class QuorumStateResolver:
"""Calculates a list of state transitions and yields them as :class:`Transition` named tuples.
Synchronous replication state is set in two places:
@@ -142,6 +144,7 @@ class QuorumStateResolver(object):
.. seealso::
Check :class:`QuorumStateResolver`'s docstring for more information.
:raises:
:exc:`QuorumError`: in case of broken state"""
voters = CaseInsensitiveSet(self.voters | CaseInsensitiveSet([self.leader]))