8000 Synchronous standbys by zilder · Pull Request #46 · postgrespro/testgres · GitHub
[go: up one dir, main page]

Skip to content

Synchronous standbys #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix formatting, make standby.First and standby.Any classes available …
…from top level module
  • Loading branch information
zilder committed May 31, 2018
commit 45c837806531fc220755fbbab36830b79c94a1c2
4 changes: 4 additions & 0 deletions testgres/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
get_bin_path, \
get_pg_config, \
get_pg_version

from .standby import \
First, \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO those names are too generic to be exported at top level.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think names are ok but should be used with the of module, like standby.First

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ildus I agree.

Any
4 changes: 3 additions & 1 deletion testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,10 @@ def set_synchronous_standbys(self, standbys):

Example::

from testgres import get_new_node, First

master = get_new_node().init().start()
with master.replicate.start() as standby:
with master.replicate().start() as standby:
master.append_conf("synchronous_commit = remote_apply")
master.set_synchronous_standbys(First(1, [standby]))
master.restart()
Expand Down
40 changes: 20 additions & 20 deletions testgres/standby.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
@six.python_2_unicode_compatible
class First:
"""
Specifies a priority-based synchronous replication and makes transaction
commits wait until their WAL records are replicated to ``num_sync``
synchronous standbys chosen based on their priorities.

Args:
sync_num (int): the number of standbys that transaction need to wait
for replies from
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
nodes
"""
Specifies a priority-based synchronous replication and makes transaction
commits wait until their WAL records are replicated to ``num_sync``
synchronous standbys chosen based on their priorities.

Args:
sync_num (int): the number of standbys that transaction need to wait
for replies from
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
nodes
"""

def __init__(self, sync_num, standbys):
self.sync_num = sync_num
Expand All @@ -29,16 +29,16 @@ def __str__(self):
@six.python_2_unicode_compatible
class Any:
"""
Specifies a quorum-based synchronous replication and makes transaction
commits wait until their WAL records are replicated to at least ``num_sync``
listed standbys. Only available for Postgres 10 and newer.

Args:
sync_num (int): the number of standbys that transaction need to wait
for replies from
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
nodes
"""
Specifies a quorum-based synchronous replication and makes transaction
commits wait until their WAL records are replicated to at least ``num_sync``
listed standbys. Only available for Postgres 10 and newer.

Args:
sync_num (int): the number of standbys that transaction need to wait
for replies from
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
nodes
"""

def __init__(self, sync_num, standbys):
self.sync_num = sync_num
Expand Down
0