Skip to content

coordinator: handle fast-fail errors before checkpoint progress - #5424

Merged
ti-chi-bot[bot] merged 4 commits into
pingcap:masterfrom
3AceShowHand:fix-fast-fail-error
Jun 17, 2026
Merged

coordinator: handle fast-fail errors before checkpoint progress#5424
ti-chi-bot[bot] merged 4 commits into
pingcap:masterfrom
3AceShowHand:fix-fast-fail-error

Conversation

@3AceShowHand

@3AceShowHand 3AceShowHand commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #5246

Maintainer heartbeat can carry both checkpoint progress and an unretryable error in the same MaintainerStatus. Before this PR, Backoff.CheckStatus handled checkpoint progress before checking status.Err, so a fast-fail error such as ErrTableRouteConflict could be ignored when the checkpoint advanced in the same report. Since maintainer-reported errors are transient, the changefeed could remain normal instead of moving to failed.

This was observed in the table route conflict detection flow: the route conflict was detected and reported by the maintainer, but coordinator treated the heartbeat as normal progress and only persisted the checkpoint.

What is changed and how it works?

  • Check fast-fail / unretryable errors before checkpoint progress in Backoff.CheckStatus.
  • Keep the backoff checkpoint monotonic when a fast-fail status also reports a newer checkpoint.
  • Reuse one helper for fast-fail classification in both CheckStatus and HandleError.
  • Add regression coverage for ErrTableRouteConflict and for fast-fail errors reported together with checkpoint progress.

This PR intentionally does not change retryable-error precedence. Retryable errors that arrive with checkpoint progress still follow the existing recovery semantics; that broader behavior should be handled separately if needed.

Check List

Tests

  • Unit test

Questions

Will it cause performance regression or break compatibility?

No. The change only reorders coordinator-side classification for fast-fail / unretryable errors in maintainer status handling.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

Fix a bug that unretryable changefeed errors could be ignored when checkpoint advances in the same maintainer heartbeat.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved fast-fail handling so critical errors immediately transition the changefeed to Failed, stopping retries and preventing checkpoint/progress updates from overriding the failed state.
    • Prevented possible issues by safely handling missing heartbeat error details during fast-fail decisions.
  • Tests
    • Added fast-fail coverage for table route conflicts, including verifying failed-state persistence across checkpoint advancement.
    • Added tests for fast-fail and retryable behavior when bootstrap completion status changes.

@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 16, 2026
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ea4db0d5-72b7-49d0-af0e-b5e4c5eff9e2

📥 Commits

Reviewing files that changed from the base of the PR and between d45d109 and 546ae1d.

📒 Files selected for processing (3)
  • coordinator/changefeed/backoff.go
  • coordinator/changefeed/changefeed.go
  • coordinator/changefeed/changefeed_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • coordinator/changefeed/backoff.go

📝 Walkthrough

Walkthrough

Backoff gains a new checkFailedStatus helper that centralizes terminal state detection by scanning for fast-fail errors before checkpoint progress, with an immediate StateFailed return if already failed. CheckStatus delegates to checkFailedStatus for early exit. A new findFastFailError helper encapsulates fast-fail detection; HandleError uses it to simplify logic. ShouldFailChangefeed gets a nil guard. Changefeed.UpdateStatus integrates checkFailedStatus early with conditional early return only on StateFailed, deferring result return until after BootstrapDone/TargetTs checks. Tests verify fast-fail precedence and checkpoint handling in both components.

Changes

Fast-fail error handling and early exit integration

Layer / File(s) Summary
Core helpers and nil guard in Backoff
coordinator/changefeed/backoff.go
Updates imports to use github.com/pingcap/ticdc/pkg/errors directly. Introduces checkFailedStatus helper that centralizes terminal state detection: immediately returns StateFailed when m.failed is set, otherwise scans status.Err for fast-fail errors, and on match optionally advances checkpointTs, logs the event, marks m.failed, and returns StateFailed. Adds findFastFailError helper that iterates through error slices, skips nil entries, and returns the first matching fast-fail error. Adds nil guard to ShouldFailChangefeed to return false instead of panicking on nil *heartbeatpb.RunningError.
Early fast-fail exit in Backoff.CheckStatus
coordinator/changefeed/backoff.go
CheckStatus calls checkFailedStatus at the start and returns immediately when it reports config.StateFailed, bypassing the normal warning/retry path. This ensures fast-fail errors are handled before checkpoint progress advances.
Early fast-fail evaluation in Changefeed.UpdateStatus
coordinator/changefeed/changefeed.go
UpdateStatus calls c.backoff.checkFailedStatus(newStatus) immediately after storing c.status. If the returned state is config.StateFailed, it returns early. Otherwise it continues evaluating existing BootstrapDone and TargetTs transition logic, then returns the previously computed result, preserving the existing control flow for those paths.
Backoff fast-fail test coverage
coordinator/changefeed/backoff_test.go
Adds ErrTableRouteConflict as a table-driven test case in TestTableRoutingErrorsFastFail. Adds TestFastFailErrorWinsOverCheckpointProgress, which asserts that a table route conflict error causes StateFailed at failure time, records the checkpoint, and that a subsequent CheckpointTs increase does not clear the failed state or override the stored checkpoint.
Changefeed UpdateStatus fast-fail test coverage
coordinator/changefeed/changefeed_test.go
Adds github.com/pingcap/ticdc/pkg/errors import. Adds TestChangefeed_UpdateStatusFastFailWhenBootstrapDoneChanges, which verifies that when BootstrapDone becomes true with a fast-fail RunningError, UpdateStatus returns StateFailed, the same error instance, updates internal status, and disables execution. Adds TestChangefeed_UpdateStatusRetryableErrorWhenBootstrapDoneChanges, which covers the retryable error path: UpdateStatus returns StateNormal on first call with ShouldRun() == true, then transitions to StateWarning on the next call with ShouldRun() == false.

Sequence Diagram(s)

sequenceDiagram
  participant UpdateStatus as Changefeed.UpdateStatus
  participant CheckFailed as checkFailedStatus
  participant FindFastFail as findFastFailError
  participant Log as Logger

  UpdateStatus->>UpdateStatus: Store c.status
  UpdateStatus->>CheckFailed: Call checkFailedStatus(newStatus)
  CheckFailed->>CheckFailed: Check if m.failed already set
  CheckFailed->>FindFastFail: Scan status.Err for fast-fail
  FindFastFail-->>CheckFailed: Fast-fail error found
  CheckFailed->>CheckFailed: Conditionally advance checkpointTs
  CheckFailed->>Log: Log fast-fail event
  CheckFailed->>CheckFailed: Set m.failed = true
  CheckFailed-->>UpdateStatus: Return (changed, StateFailed, err)
  UpdateStatus->>UpdateStatus: Check early-return condition
  UpdateStatus-->>UpdateStatus: Return immediately on StateFailed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • coordinator: clarify CheckStatus error handling precedence #5246: The PR implements the fast-fail error precedence fix discussed in this issue, introducing the checkFailedStatus helper to ensure fast-fail errors are evaluated before checkpoint progress in Backoff.CheckStatus, directly addressing the table-route conflict handling path.

Suggested labels

lgtm, size/M, needs-cherry-pick-release-8.5

Suggested reviewers

  • wk989898
  • lidezhu
  • asddongmen

Poem

🐇 A helper hops through status checks,
Fast-fail errors—no more wrecks!
Early exit, clear and bright,
Checkpoint logic flows just right.
Fast-fail wins before retry's call—
CodeRabbit loves this change most of all! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'coordinator: handle fast-fail errors before checkpoint progress' directly and clearly summarizes the main change: reordering error checking to prioritize fast-fail errors over checkpoint progress, which is the core fix described in the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 16, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces fast-fail error handling in the changefeed backoff coordinator. It updates CheckStatus to detect fast-fail errors via a new helper function findFastFailError, refactors HandleError to use this helper, and adds corresponding unit tests. The review feedback suggests adding defensive checks: a nil check for status in CheckStatus to prevent potential nil pointer dereferences, and an empty-slice check in HandleError to avoid out-of-bounds panics.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread coordinator/changefeed/backoff.go
Comment thread coordinator/changefeed/backoff.go
@3AceShowHand

Copy link
Copy Markdown
Collaborator Author

/test all

@3AceShowHand 3AceShowHand changed the title fast fail on error coordinator: handle fast-fail errors before checkpoint progress Jun 16, 2026
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 17, 2026
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 17, 2026
@3AceShowHand

Copy link
Copy Markdown
Collaborator Author

/test all

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@coordinator/changefeed/changefeed.go`:
- Around line 177-180: The early return condition on line 178 in the CheckStatus
block is too broad by returning when changed is true, which skips the TargetTs
completion logic on lines 189-193. This causes incorrect state reporting when
both checkpoint recovery and target completion occur in the same heartbeat.
Narrow the if condition to only return early on actual failure outcomes by
removing the changed clause, keeping only the error check and StateFailed state
check: err != nil || state == config.StateFailed. This allows valid recovery
transitions with changed true to continue executing the TargetTs completion
logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f8ce2c00-95dd-4289-9d07-274dc345f644

📥 Commits

Reviewing files that changed from the base of the PR and between d6cd64d and 913158e.

📒 Files selected for processing (3)
  • coordinator/changefeed/backoff.go
  • coordinator/changefeed/changefeed.go
  • coordinator/changefeed/changefeed_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • coordinator/changefeed/backoff.go

Comment thread coordinator/changefeed/changefeed.go Outdated
@3AceShowHand

Copy link
Copy Markdown
Collaborator Author

/test all

@3AceShowHand

Copy link
Copy Markdown
Collaborator Author

/test all

@ti-chi-bot ti-chi-bot Bot added the lgtm label Jun 17, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hongyunyan, wk989898

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [hongyunyan,wk989898]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 17, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-17 03:01:39.32559417 +0000 UTC m=+1533800.395911560: ☑️ agreed by wk989898.
  • 2026-06-17 08:46:51.161243012 +0000 UTC m=+1554512.231560392: ☑️ agreed by hongyunyan.

@ti-chi-bot
ti-chi-bot Bot merged commit 05aa985 into pingcap:master Jun 17, 2026
25 checks passed
@3AceShowHand

Copy link
Copy Markdown
Collaborator Author

/cherry-pick release-8.5

@ti-chi-bot

Copy link
Copy Markdown
Member

@3AceShowHand: new pull request created to branch release-8.5: #5771.

Details

In response to this:

/cherry-pick release-8.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coordinator: clarify CheckStatus error handling precedence

4 participants