Skip to content

downstreamadapter: harden table trigger takeover (#5436) - #5792

Merged
ti-chi-bot[bot] merged 3 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-5436-to-release-8.5
Jul 30, 2026
Merged

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

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #5436

What problem does this PR solve?

Issue Number: close #5083

This is PR 3 of 3 split from #5182 and is stacked on PR 2.

Background:

PR 1 persists maintainer epochs before ownership changes. PR 2 fences stale
maintainer control messages at the maintainer and dispatcher-manager boundary.
This final PR hardens the table trigger takeover cases that still depend on
dispatcher-manager bootstrap recovery.

Motivation:

During a same-capture higher-epoch maintainer replacement, a reused dispatcher
manager can still have table trigger event or redo dispatchers from the previous
owner. Replacing a mismatched trigger in place can duplicate DDL ownership, while
dropping stale remove operators during bootstrap can lose the cleanup intent for
an already reported dispatcher.

What is changed and how it works?

This PR adds takeover-specific hardening:

  • Verifies that a reused dispatcher manager either has no table trigger
    dispatcher yet or already has the trigger dispatcher requested by the current
    bootstrap owner.
  • Creates missing event and redo table trigger dispatchers during bootstrap, but
    rejects mismatched trigger IDs instead of replacing them in place.
  • Restores stale remove operators in bootstrap responses only when the same
    bootstrap snapshot reports the dispatcher they remove.
  • Keeps current-epoch bootstrap operators while filtering stale create operators.
  • Adds unit coverage for stale remove restoration, bootstrap snapshot filtering,
    close acknowledgements, closed-epoch tombstones, and table trigger ID mismatch
    handling.
  • Updates the in-flight syncpoint scheduling integration case to search all CDC
    node logs because the merge task may run on any dispatcher-manager owner after
    scheduling.

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
  • Integration test

Questions

Will it cause performance regression or break compatibility?

No expected performance regression. The added checks run during maintainer
bootstrap and bootstrap response reconstruction, not on the event write path.

The behavior is compatible with rolling upgrades because it builds on the epoch
0 compatibility rules introduced in the previous PRs.

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

No.

Release note

Fix a bug where delayed stale maintainer requests could create duplicate dispatchers during maintainer failover.

Validation

  • make fmt
  • go test ./downstreamadapter/dispatcherorchestrator ./downstreamadapter/dispatchermanager

Summary by CodeRabbit

  • New Features
    • Added maintainer-epoch checks for maintainer bootstrap updates and redo control message processing.
    • Extended redo control messages to include sender context and maintainer_epoch for tighter stale protection.
  • Bug Fixes
    • Prevented stale maintainer/redo requests from overriding newer dispatcher or redo state, including during bootstrap and close handling.
    • Improved bootstrap/trigger validation and ensured “write path closed” behavior releases fencing without surfacing bootstrap errors.
  • Tests
    • Expanded unit and orchestration coverage for maintainer-epoch gating, stale redo drops, pending-queue precedence, and updated multi-node integration log assertions.

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 Denotes a PR that will be considered when it comes time to generate release notes. 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: de5aacf7-142f-4983-a92e-316d25d0c4db

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 ti-chi-bot Bot added 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

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 30, 2026
@hongyunyan

Copy link
Copy Markdown
Contributor

/unhold

@ti-chi-bot

ti-chi-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hongyunyan

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 added the approved label Jul 30, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 2a1e7b0 into pingcap:release-8.5 Jul 30, 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 Denotes a PR that will be considered when it comes time to generate release notes. 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.

2 participants