Skip to content

schemastore: stop GC keeper for tombstone keyspace - #6159

Open
asddongmen wants to merge 1 commit into
pingcap:masterfrom
asddongmen:fix-tombstone-keyspace-gc-keeper
Open

schemastore: stop GC keeper for tombstone keyspace#6159
asddongmen wants to merge 1 commit into
pingcap:masterfrom
asddongmen:fix-tombstone-keyspace-gc-keeper

Conversation

@asddongmen

@asddongmen asddongmen commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #6156

After PD tombstones a keyspace, its per-node schema-store GC keeper keeps trying to refresh the keyspace safepoint every two minutes. PD rejects every request, but the keeper treats the failure as retryable forever, causing useless requests and recurring warnings until TiCDC restarts.

What is changed and how it works?

After a NextGen safepoint refresh fails, the keeper loads the keyspace metadata from PD. If PD confirms the irreversible TOMBSTONE state, the keeper logs the terminal lifecycle event once and exits its refresh goroutine.

Successful refreshes do not add a metadata request. Enabled keyspaces and metadata lookup failures retain the existing retry behavior. A table-driven unit test covers all four paths.

Check List

Tests

  • Unit test
    • NextGen and classic GC-keeper test groups
    • NextGen GC-keeper tests with the race detector

Questions

Will it cause performance regression or break compatibility?

No. The additional PD request is made only after a failed NextGen safepoint refresh. Classic mode and retryable failures are unchanged.

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

No. This fixes an internal lifecycle error path without changing user-facing configuration or APIs.

Release note

Fix TiCDC repeatedly refreshing the GC safepoint after a keyspace becomes tombstone.

Summary by CodeRabbit

  • Bug Fixes
    • Schema store garbage collection now stops refreshing safepoints after a keyspace is tombstoned.
    • Temporary refresh failures continue to be handled without prematurely stopping the refresh process.
  • Tests
    • Added coverage for tombstoned keyspaces, successful refreshes, temporary errors, and keyspace state lookup failures.

@ti-chi-bot ti-chi-bot Bot added needs-cherry-pick-release-nextgen-202603 Should cherry pick this PR to release-nextgen-202603 branch. 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. labels Sep 3, 2026
@coderabbitai

coderabbitai Bot commented Sep 3, 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: Team

Run ID: c2e73632-ea0b-4e56-894d-d6ae68182402

📥 Commits

Reviewing files that changed from the base of the PR and between fb743a8 and 40dbd02.

📒 Files selected for processing (2)
  • logservice/schemastore/gc_keeper.go
  • logservice/schemastore/gc_keeper_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The schema store GC keeper now stops its refresh loop when PD reports a non-classic keyspace as TOMBSTONE. Tests cover refresh outcomes and keyspace lookup behavior with a mock PD client.

Changes

GC keeper tombstone handling

Layer / File(s) Summary
Tombstone-aware refresh logic
logservice/schemastore/gc_keeper.go
The keeper uses refreshSafepoint to inspect keyspace state after refresh failures. It stops for TOMBSTONE in non-classic kernel mode and continues for other failures.
Refresh outcome tests
logservice/schemastore/gc_keeper_test.go
Table-driven tests cover successful refreshes, tombstoned keyspaces, temporary refresh errors, and keyspace lookup failures with a mock PD client.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 40dbd

The GC keeper now stops refreshing safepoints after PD confirms a keyspace is tombstoned, preventing repeated requests and warnings for deleted keyspaces while retaining retry behavior for transient failures. No current merge-blocking risk is identified.

Suggested reviewers: wk989898

Poem

A rabbit watched the keeper’s round,
As safepoints refreshed all around.
“TOMBSTONE,” said PD, “now rest,”
The loop stopped softly at request.
Tests hopped through each state with care.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR satisfies the requirement to stop indefinite safepoint-refresh retries after PD reports TOMBSTONE, and it preserves retry behavior for other failures [#6156]. However, the linked issue also req… Implement keyspace schema-store cleanup and unregistration after no changefeed or local consumer remains, using reference counting or another explicit lifecycle mechanism that supports multiple changefeeds and per-node consumers. Alternativ…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: stopping the schema-store GC keeper when a keyspace becomes tombstone.
Description check ✅ Passed The description includes the required issue reference, problem statement, implementation details, tests, compatibility assessment, documentation assessment, and release note.
Out of Scope Changes check ✅ Passed The production changes and table-driven tests are directly related to handling TOMBSTONE keyspaces and preventing repeated GC safepoint refresh attempts. No unrelated changes are evident.
Full details: Linked Issues check

Explanation

The PR satisfies the requirement to stop indefinite safepoint-refresh retries after PD reports TOMBSTONE, and it preserves retry behavior for other failures [#6156]. However, the linked issue also requires stopping and cleaning up the keyspace schema store with lifecycle handling for shared keyspaces and per-node consumers. This PR does not implement that cleanup.

Resolution

Implement keyspace schema-store cleanup and unregistration after no changefeed or local consumer remains, using reference counting or another explicit lifecycle mechanism that supports multiple changefeeds and per-node consumers. Alternatively, split or revise the linked issue if that broader cleanup is intentionally out of scope for this PR.

  • Fix all pre-merge checks with AI
✨ 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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 3, 2026
@asddongmen asddongmen added the hold This pull request is not ready to merge. label Sep 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3AceShowHand, 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:
  • OWNERS [3AceShowHand,lidezhu]

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 4, 2026
@ti-chi-bot

ti-chi-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-09-03 07:34:16.289044937 +0000 UTC m=+1351091.460139050: ☑️ agreed by lidezhu.
  • 2026-09-04 09:10:42.266935705 +0000 UTC m=+1443277.438029820: ☑️ agreed by 3AceShowHand.

@ti-chi-bot

ti-chi-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

@asddongmen: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cdc-storage-integration-heavy-next-gen 40dbd02 link unknown /test pull-cdc-storage-integration-heavy-next-gen
pull-cdc-mysql-integration-heavy 40dbd02 link unknown /test pull-cdc-mysql-integration-heavy
pull-cdc-mysql-integration-heavy-next-gen-legacy-safepoint 40dbd02 link unknown /test pull-cdc-mysql-integration-heavy-next-gen-legacy-safepoint

Full PR test history. Your PR dashboard.

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved hold This pull request is not ready to merge. lgtm needs-cherry-pick-release-nextgen-202603 Should cherry pick this PR to release-nextgen-202603 branch. 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.

schemastore: stop GC keeper after keyspace becomes tombstone

3 participants