Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[#249] Fix of port number leak in NodeBackup::spawn_replica #250

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
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
Prev Previous commit
Next Next commit
[#249] NodeBackup::spawn_replica does not release a reserved port num…
…ber during failure

NodeBackup::spawn_replica uses an explict "rollback" code to destroy a newly allocated node to release a reserved port number.
  • Loading branch information
dmitry-lipetsk committed May 4, 2025
commit 02f7f00d380c7455d42ae17480880afdf2be733f
11 changes: 8 additions & 3 deletions testgres/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,19 @@ def spawn_replica(self, name=None, destroy=True, slot=None):
"""

# Build a new PostgresNode
with clean_on_error(self.spawn_primary(name=name,
destroy=destroy)) as node:
node = self.spawn_primary(name=name, destroy=destroy)
assert node is not None

try:
# Assign it a master and a recovery file (private magic)
node._assign_master(self.original_node)
node._create_recovery_conf(username=self.username, slot=slot)
except: # noqa: E722
# TODO: Pass 'final=True' ?
node.cleanup(release_resources=True)
raise

return node
return node

def cleanup(self):
"""
Expand Down