Skip to content

fix(*): merge operator inconsistent after maintainer move (#3769) - #5817

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

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

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #3769

What problem does this PR solve?

Issue Number: close #4763

Maintainer bootstrap rebuilds running spans from dispatcher-manager snapshots, but before this change it did not fully rebuild in-flight operator state after maintainer failover.

There were two gaps:

  • bootstrap recovery for create/remove-based operators still had corner cases, so add/remove/move/split could leave duplicate tasks, ghost spans, or stale removed dispatchers after maintainer restart;
  • merge uses MergeDispatcherRequest instead of ScheduleDispatcherRequest, but dispatcher managers did not persist in-flight merge requests in bootstrap responses, so a maintainer move could lose the merge intent entirely and leave the source dispatchers or merged dispatcher stuck in an intermediate state.

As a result, table scheduling might not converge automatically after maintainer failover, especially when failover happens while add/remove/move/split/merge is still in progress.

What is changed and how it works?

  • Persist in-flight merge requests in dispatcher manager state and include them in MaintainerBootstrapResponse.
  • Restore merge operators during bootstrap by rebuilding source and merged replica sets from bootstrap spans, re-creating occupy operators, and resuming the merge state machine with the original merged dispatcher ID.
  • Harden bootstrap recovery for create/remove/move/split operators:
    • normalize missing span/schema information from bootstrap span snapshots;
    • skip stale create requests for tables that are already absent from the schema-store snapshot;
    • rebuild missing replica sets for remove requests and bind them to the reporting node when needed;
    • avoid creating duplicate tasks when restored operators have already populated spanController;
    • only mark move/split replicas absent if the task still exists, so concurrent DDL does not reintroduce ghost spans;
    • only finish remove operators on Stopped or Removed, not transient states such as WaitingMerge.
  • Extend maintainer_failover_when_operator integration coverage to cover merge recovery and make the test runnable against non-default local ports for isolated local reruns.

Check List

Tests

  • Integration test
  • Manual test

Questions

Will it cause performance regression or break compatibility?

No. This only changes bootstrap recovery for in-flight scheduling state after maintainer failover and does not change steady-state scheduling behavior or external compatibility.

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

No.

Release note

Fix an issue where maintainer failover could leave in-flight scheduling or merge operators inconsistent and prevent table convergence.

Summary by CodeRabbit

  • New Features

    • Added in-flight merge-operator tracking and automatic restoration during maintainer failover.
    • Maintainer bootstrap now propagates merge operators and reconstructs merge dispatchers from existing span snapshots.
  • Bug Fixes

    • Improved bootstrap hole detection to tolerate overlapping spans and removed a panic condition for out-of-order assumptions.
    • Extended merge cleanup to remove merge-operator state on both success and abort.
  • Tests

    • Added failover and overlap-coverage bootstrap test cases for in-flight merges, plus integration coverage for merge scenarios.
  • Chores

    • Updated failover test configuration and utilities to support merge validation and dynamic upstream connection settings.

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 29, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

@wlwilliamx 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 added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jul 29, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 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 29, 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: ef3d5977-0c36-4b47-a56f-deaed708c296

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

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 commented Jul 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wlwilliamx

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 29, 2026
@wlwilliamx

Copy link
Copy Markdown
Collaborator

/test all

Keep release-8.5-specific scheduling behavior while adapting the merge recovery changes and generated protobuf output.

Signed-off-by: wlwilliamx <wlwilliamx@gmail.com>
@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
@wlwilliamx

Copy link
Copy Markdown
Collaborator

/unhold

Preserve maintainer epoch fencing and bootstrap recovery.

Keep both merge journaling and bootstrap coverage repair.

Signed-off-by: wlwilliamx <wlwilliamx@gmail.com>
@wlwilliamx

Copy link
Copy Markdown
Collaborator

/test all

@wlwilliamx

Copy link
Copy Markdown
Collaborator

/retest

1 similar comment
@wlwilliamx

Copy link
Copy Markdown
Collaborator

/retest

Preserve merge recovery while integrating redo maintainer epoch fencing.

Signed-off-by: wlwilliamx <wlwilliamx@gmail.com>
@ti-chi-bot
ti-chi-bot Bot merged commit 67fafe4 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