From ebdc197f088a3d186dfb664656b741174403b972 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 25 Oct 2023 11:23:39 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Israel --- patroni/ha.py | 12 ++++++------ patroni/quorum.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/patroni/ha.py b/patroni/ha.py index b0f5f476..41eadc10 100644 --- a/patroni/ha.py +++ b/patroni/ha.py @@ -698,7 +698,7 @@ class Ha(object): return self.global_config.is_synchronous_mode def is_quorum_commit_mode(self) -> bool: - """:returns: `True` if quorum commit replication is requested and "supported".""" + """``True`` if quorum commit replication is requested and "supported".""" return self.global_config.is_quorum_commit_mode and self.state_handler.supports_multiple_sync def is_failsafe_mode(self) -> bool: @@ -732,8 +732,8 @@ class Ha(object): def _process_quorum_replication(self) -> None: """Process synchronous replication state when quorum commit is requested. - Synchronous standbys are registered in two places postgresql.conf and DCS. The order of updating them must - keep the invariant that `quorum + sync >= len(set(quorum pool)|set(sync pool))`. This is done using + Synchronous standbys are registered in two places: ``postgresql.conf`` and DCS. The order of updating them must + keep the invariant that ``quorum + sync >= len(set(quorum pool)|set(sync pool))``. This is done using :class:`QuorumStateResolver` that given a current state and set of desired synchronous nodes and replication level outputs changes to DCS and synchronous replication in correct order to reach the desired state. In case any of those steps causes an error we can just bail out and let next iteration rediscover the state @@ -876,7 +876,7 @@ class Ha(object): we can promote immediately and let normal quorum resolver process handle any membership changes later. Otherwise, we will just reset DCS state to ourselves and add replicas as they connect. - :returns: `True` if on success or `False` if failed to update /sync key in DCS. + :returns: ``True`` if on success or ``False`` if failed to update /sync key in DCS. """ if not self.is_synchronous_mode(): self.disable_synchronous_replication() @@ -1122,7 +1122,7 @@ class Ha(object): :param wal_position: Current wal position. - :returns `True` when node is lagging + :returns: ``True`` when node is lagging """ lag = (self.cluster.last_lsn or 0) - wal_position return lag > self.global_config.maximum_lag_on_failover @@ -1133,7 +1133,7 @@ class Ha(object): :param members: the list of nodes to check against :param check_replication_lag: whether to take the replication lag into account. If the lag exceeds configured threshold the node disqualifies itself. - :returns: `True` if the node is eligible to become the new leader. Since this method is executed + :returns: ``True`` if the node is eligible to become the new leader. Since this method is executed on multiple nodes independently it is possible that multiple nodes could count themselves as the healthiest because they received/replayed up to the same LSN, but this is totally fine. diff --git a/patroni/quorum.py b/patroni/quorum.py index 120c5e0d..059c8acc 100644 --- a/patroni/quorum.py +++ b/patroni/quorum.py @@ -253,7 +253,7 @@ class QuorumStateResolver: break def __handle_non_steady_cases(self) -> Iterator[Transition]: - """Handle cases when set of transitions produces on previous run was interrupted. + """Handle cases when set of transitions produced on previous run was interrupted. :yields: transitions as :class:`Transition` objects. """