Skip to content

gc,server: add GC state cache test coverage#10617

Merged
ti-chi-bot[bot] merged 2 commits into
tikv:release-fts-202602from
wfxr:test/gc-states-cache
Apr 27, 2026
Merged

gc,server: add GC state cache test coverage#10617
ti-chi-bot[bot] merged 2 commits into
tikv:release-fts-202602from
wfxr:test/gc-states-cache

Conversation

@wfxr
Copy link
Copy Markdown

@wfxr wfxr commented Apr 23, 2026

What problem does this PR solve?

Issue Number: Ref #10607

What is changed and how does it work?

gc,server: add GC state cache test coverage

Add focused unit and integration coverage for the GC state cache behavior
introduced by GetGCState caching.

The added tests cover cache hit/miss behavior, cache update and invalidation
paths, and leader transition semantics for both cached and uncached requests.

This PR supplements the GC state cache change with focused test coverage.

Checklist of covered scenarios:

  • The target keyspace has no cache beforehand
    • Concurrent GetGCState on the same uncached keyspace
    • Request old leader after leader switch
    • No-cache slow path loses leadership and does not recover
    • No-cache slow path loses and then regains leadership
    • Storage read failure does not populate cache
    • Delete barrier before cache exists
  • The target keyspace already has cache
    • Concurrent GetGCState on the same cached keyspace
    • Request old leader after leader switch
    • Cache-hit request loses leadership before response
    • Cache-hit request loses and then regains leadership
    • Delete barrier after cache exists
    • Advance GC safepoint after cache exists
    • Add or update barrier after cache exists
    • Delete legacy service GC safepoint

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. labels Apr 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: d5bd0ed9-f85a-4ed0-8740-517a90ddf3d4

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 and usage tips.

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Apr 23, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 23, 2026

Hi @wfxr. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@ti-chi-bot ti-chi-bot Bot added the first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. label Apr 23, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 23, 2026

Welcome @wfxr!

It looks like this is your first PR to tikv/pd 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to tikv/pd. 😃

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 23, 2026
@wfxr wfxr marked this pull request as ready for review April 23, 2026 03:54
@ti-chi-bot ti-chi-bot Bot added dco-signoff: no Indicates the PR's author has not signed dco. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. labels Apr 23, 2026
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
@wfxr wfxr force-pushed the test/gc-states-cache branch from 8a3cfb7 to 45b7d41 Compare April 23, 2026 04:13
@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. and removed dco-signoff: no Indicates the PR's author has not signed dco. labels Apr 23, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 23, 2026

@MyonKeminta: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

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.

res := <-resultCh
re.NoError(res.err)
re.Nil(res.resp.GetHeader().GetError())
re.Equal(uint64(10), res.resp.GetGcState().GetTxnSafePoint())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it meet the expectation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mainly meant to pin the current cache-hit behavior rather than define the ideal long-term contract.

In this scenario, the request has already copied the cached GC state before the leadership churn. The current handler only rechecks whether this PD is leader again before replying, so if the same PD regains leadership before the final response check, it can return that earlier cached value.

I updated the test comment to make this explicit and to avoid implying that this stale snapshot is a permanent/ideal API contract. If we decide to tighten GetGCState semantics in the future, the implementation, docs, and this test should be updated together.

@rleungx
Copy link
Copy Markdown
Member

rleungx commented Apr 23, 2026

/ok-to-test

@ti-chi-bot ti-chi-bot Bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.86%. Comparing base (4b9dde5) to head (30f8961).
⚠️ Report is 1 commits behind head on release-fts-202602.

Additional details and impacted files
@@                  Coverage Diff                   @@
##           release-fts-202602   #10617      +/-   ##
======================================================
+ Coverage               77.20%   78.86%   +1.65%     
======================================================
  Files                     524      524              
  Lines                   84076    70599   -13477     
======================================================
- Hits                    64908    55675    -9233     
+ Misses                  15190    10943    -4247     
- Partials                 3978     3981       +3     
Flag Coverage Δ
unittests 78.86% <100.00%> (+1.65%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
@wfxr wfxr force-pushed the test/gc-states-cache branch from b909965 to 30f8961 Compare April 23, 2026 10:07
@wfxr wfxr requested a review from rleungx April 24, 2026 02:18
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 24, 2026
@ti-chi-bot ti-chi-bot Bot added the approved label Apr 24, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MyonKeminta, okJiang, rleungx

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 27, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 27, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-24 03:21:11.002699103 +0000 UTC m=+2308876.208059159: ☑️ agreed by rleungx.
  • 2026-04-27 02:22:17.000651614 +0000 UTC m=+2564542.206011671: ☑️ agreed by okJiang.

@ti-chi-bot ti-chi-bot Bot merged commit 9d37cba into tikv:release-fts-202602 Apr 27, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. lgtm ok-to-test Indicates a PR is ready to be tested. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants