diff --git a/patroni/postgresql/sync.py b/patroni/postgresql/sync.py index b503af43..067583d7 100644 --- a/patroni/postgresql/sync.py +++ b/patroni/postgresql/sync.py @@ -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. diff --git a/patroni/quorum.py b/patroni/quorum.py index 2d75f0c0..c510cfca 100644 --- a/patroni/quorum.py +++ b/patroni/quorum.py @@ -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]))