Skip to content

coordinator: persist maintainer epochs before ownership changes (#5434) - #5788

Merged
ti-chi-bot[bot] merged 5 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-5434-to-release-8.5
Jul 29, 2026
Merged

ti-chi-bot[bot] merged 5 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-5434-to-release-8.5

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #5434

What problem does this PR solve?

Issue Number: ref #5083

This is PR 1 of 3 split from #5182.

Background:

During maintainer failover, the coordinator can schedule a new maintainer while
delayed requests from the previous maintainer are still in flight. Receiver-side
fencing only works if every new ownership attempt has a persisted, monotonic
maintainer epoch before any add or move request is sent.

Motivation:

The old code generated owner epochs from in-memory state and resumed changefeeds
with a normal metadata write. That made it hard to prove that a new maintainer
owner is always ordered after the previously persisted owner, especially across
coordinator failover, resume, retry, and move paths.

What is changed and how it works?

This PR adds the coordinator-side epoch persistence foundation:

  • Adds optional maintainer epoch fields to maintainer lifecycle, scheduling,
    heartbeat, and close messages.
  • Adds common maintainer epoch matching helpers and PD TSO based epoch generation.
  • Adds BumpChangefeedEpoch to atomically persist a strictly newer changefeed
    epoch, optionally with status updates under the same etcd transaction.
  • Uses the persisted epoch bump before add/move operators, resume, and warning
    retry scheduling can create a new maintainer owner.
  • Keeps add-maintainer config bytes synchronized with the latest persisted
    ChangeFeedInfo.
  • Makes coordinator bootstrap select the current-epoch maintainer and stop stale
    reported owners with their original epoch.
  • Carries the origin epoch through stop and move operators so old owners are
    fenced by the epoch they actually own.

Stack:

  • #5434: coordinator epoch persistence and owner scheduling foundation.
  • #5435: maintainer and dispatcher-manager receiver-side epoch fence.
  • #5436: table trigger takeover hardening and integration coverage.

Check List

Tests

  • Unit test

Questions

Will it cause performance regression or break compatibility?

No expected performance regression. Epoch bumps happen on ownership-changing
control paths such as add, move, resume, and retry scheduling, not in the event
write path.

The protobuf fields are optional. Epoch 0 remains the compatibility value used
by old components until later PRs enforce strict receiver-side fences.

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

No.

Release note

None

Validation

  • make generate-protobuf
  • make fmt
  • go test ./coordinator/changefeed ./coordinator ./coordinator/operator ./pkg/pdutil

Summary by CodeRabbit

  • New Features
    • Added maintainer epoch propagation through heartbeat and maintainer lifecycle requests, including resume and stop flows.
  • Bug Fixes
    • Prevented stale maintainer reports from being applied by dropping mismatched heartbeat status.
    • Updated bootstrap/stop/remove behavior to fence stale owners while preserving the reported maintainer epoch.
  • Improvements
    • Tightened changefeed initialization/resume validation and improved warning-state handling by bumping ownership epoch before stopping.
  • Tests
    • Expanded coverage for epoch bumping, resume behavior, and maintainer-epoch propagation.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Jul 28, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

@hongyunyan This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

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.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aac8f059-02d9-4620-9c91-841c9ec35c39

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

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

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.

@ti-chi-bot

Copy link
Copy Markdown
Member Author

Cherry-pick conflicts appear resolved; removing the do-not-merge/hold label.

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 28, 2026
@ti-chi-bot ti-chi-bot Bot added approved cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jul 28, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

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 merged commit 7095297 into pingcap:release-8.5 Jul 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants