Skip to content

infosync: protect the oldest active Classic primary rollback from GC - #73624

Draft
ekexium wants to merge 1 commit into
pingcap:masterfrom
ekexium:sfs/tidb-1-infosync-gc-floor
Draft

ekexium wants to merge 1 commit into
pingcap:masterfrom
ekexium:sfs/tidb-1-infosync-gc-floor

Conversation

@ekexium

@ekexium ekexium commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: ref #73623

Problem Summary:

In TiDB Classic, TiKV data GC treats the data GC safe point inclusively and can delete a protected primary rollback record written at ts == dataSafePoint. When infosync publishes the oldest active transaction's exact startTS as the min-start-ts bound to etcd/PD, the data safe point can advance to startTS while that transaction is still active. For shared-read transactions that must reject commits at startTS <= dataSafePoint to ensure lost-read rollback evidence has not been reclaimed (tikv/client-go#2184), publishing startTS directly would either risk losing rollback evidence or falsely abort a healthy oldest reader.

What changed and how does it work?

  • When publishing the min-start-ts GC bound to etcd in Classic mode, report oldestStartTS - 1 whenever oldestStartTS > 0, placing the oldest active transaction's primary rollback strictly above the inclusive data GC safe point.
  • Keep TiDB's internally observed transaction startTS unchanged; 0 remains 0, and NextGen preserves its existing behavior.

Why this PR is isolated (Wave 1): It has no external dependency, is only +12/-1 production lines, and takes effect on all Classic clusters regardless of tidb_enable_select_for_share. Keeping it standalone enables focused review and independent rollback. Planned for cherry-pick to release-8.5 (without the kerneltype guard, as 8.5 is Classic-only).

Check List

Tests

  • Unit test (go test -count=1 ./pkg/domain/infosync/... with failpoints enabled, covering the oldestStartTS - 1 published bound, zero handling, and unchanged observable startTS)
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Publish `oldestStartTS - 1` as the Classic GC lower bound in `infosync` so the oldest active transaction's primary rollback is strictly protected from inclusive data GC.

The data GC safe point is inclusive and can delete a protected rollback exactly at startTS. Publish the predecessor of the oldest active start timestamp to PD, keeping the observable transaction start timestamp itself unchanged. This lets the coordinator reject histories already reclaimed without rejecting the oldest healthy reader.

Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ti-chi-bot

ti-chi-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-tests-checked labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@ti-chi-bot

ti-chi-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bb7133 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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 commented Nov 23, 2026

Copy link
Copy Markdown

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-tests-checked label, please finished the tests then check the finished items in description.

For example:

Tests <!-- At least one of them must be included. -->

- [x] Unit test
- [ ] Integration test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No code

‼️ Must keep the HTML comments <!-- At least one of them must be included. -->

📖 For more info, you can check the "Contribute Code" section in the development guide.

This branch has not been deployed

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

Labels

do-not-merge/needs-tests-checked do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant