Skip to content

Prevent myhoard starting more than one backup stream #155

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions myhoard/backup_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ def running(self):
yield
self.stop()

def is_in_terminal_state(self) -> bool:
"""Returns if the stream has finished operating, successfully or not"""
return bool(self.state.get("broken_info") or self.state.get("closed_info") or self.state.get("completed_info"))

def activate(self) -> None:
with self.lock:
if self.mode != self.Mode.promoted:
Expand Down
11 changes: 6 additions & 5 deletions myhoard/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,12 @@ def _check_binlog_apply_status(self) -> None:
self.state_manager.update_state(promote_details=promote_details)

def _create_new_backup_stream_if_requested_and_max_streams_not_exceeded(self):
# Only ever have two open backup streams. Uploading binlogs to more streams than that is
# unlikely to improve the system behavior. We'll create new backup stream once the latter
# one catches up with the first, the first is marked as closed, and removed from our list.
if len(self.backup_streams) >= 2:
return
# Only ever have one "active" backup stream.
# Having multiple backup streams adds complexity, increases node resource usage, and
# more easily triggers various latent bugs.
for existing_backup_stream in self.backup_streams:
if not existing_backup_stream.is_in_terminal_state():
return
with self.lock:
if self.state["backup_request"]:
request: BackupRequest = self.state["backup_request"]
Expand Down