Skip to content

Panic if InitiateHeartbeat exhausts retries to avoid looping infinitely #1574

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

Conversation

grodowski
Copy link
Contributor

Based on experience, if the writer database fails inbeetween the copy & cutover stages (e.g. during cutover pause), the heartbeat writes will fail and stop, then leading to throttled state and an infinite loop of throttler.shouldThrottle().

Since this state is irrecoverable, make the heartbeat writer panic if retries are exhausted, so that the migration can fail and be restarted later.

We've tested this in production now without issues, but if there's some desired behaviour that this PR changes, we might consider adding a new CLI option to control it - feedback welcome.

Closes #1569 (issue has some more context too)

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

Based on experience, if the writer database fails inbeetween the copy & cutover stages (e.g. during cutover pause), the heartbeat writes will fail and stop,
then leading to throttled state and an infinite loop of throttler.shouldThrottle().

Since this state is irrecoverable, make the heartbeat writer panic if retries are exhausted, so that the migration can fail and be restarted later.
@Copilot Copilot AI review requested due to automatic review settings August 6, 2025 11:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses an infinite loop issue in gh-ost where heartbeat write failures during database unavailability lead to unrecoverable throttled states. The change makes the heartbeat writer panic when retries are exhausted, allowing the migration to fail and be restarted later instead of looping indefinitely.

  • Adds panic mechanism when heartbeat injection fails after exhausting retries
  • Prevents infinite throttling loops during database failures between copy and cutover stages

@@ -574,6 +574,7 @@ func (this *Applier) InitiateHeartbeat() {
continue
}
if err := injectHeartbeat(); err != nil {
this.migrationContext.PanicAbort <- fmt.Errorf("injectHeartbeat writing failed %d times, last error: %w", numSuccessiveFailures, err)
Copy link
Preview

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The variable numSuccessiveFailures is referenced but not visible in this diff. Ensure this variable is properly defined and incremented in the retry logic to accurately reflect the number of failures.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gh-ost process stuck infinitely after writer database failure
1 participant