Skip to content

client: updating keyspace group must check the previous version#9862

Merged
ti-chi-bot[bot] merged 13 commits intotikv:masterfrom
bufferflies:keyspace/version
Nov 28, 2025
Merged

client: updating keyspace group must check the previous version#9862
ti-chi-bot[bot] merged 13 commits intotikv:masterfrom
bufferflies:keyspace/version

Conversation

@bufferflies
Copy link
Copy Markdown
Contributor

@bufferflies bufferflies commented Oct 22, 2025

What problem does this PR solve?

Issue Number: Close #6770

[Merged]kv proto: #1361

What is changed and how does it work?

'FindGroupByKeyspaceID' must carry the current keyspace group version, and the server needs to check the memory
state isn't stale, and then return the server keyspace group info.

Check List

Tests

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

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release note

None.

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Oct 22, 2025

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 do-not-merge/needs-linked-issue 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. 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. and removed do-not-merge/needs-linked-issue labels Oct 22, 2025
@bufferflies bufferflies force-pushed the keyspace/version branch 2 times, most recently from 2f5525f to 1460ce5 Compare October 23, 2025 01:17
Signed-off-by: 童剑 <1045931706@qq.com>
@bufferflies bufferflies marked this pull request as ready for review October 23, 2025 04:31
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 23, 2025
@bufferflies bufferflies changed the title client: keyspace group update must check the version avoid the stale update client: updating keyspace group must check the previous version Oct 23, 2025
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
// urls are the primary/secondary serving URL
urls []string

// version is used to avoid updating stale info
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about adding a comment to clarify where the version is sourced from and briefly explain its usage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

primaryURL: "",
secondaryURLs: make([]string, 0),
urls: make([]string, 0),
version: 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When the TSO client starts up, does it use version=0 for the initial request?

Furthermore, if this initial request is routed to a TSO service with a lower version, is that behavior expected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, this version just works for requesting the keyspace group. Most updates don't relate to this client's keyspace ID, so it doesn't need to be updated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The higher version of the server side doesn't mean that the client's keyspace group has changed.

Signed-off-by: 童剑 <1045931706@qq.com>
// version is used to avoid updating stale info
// this version is provided by etcd watcher on the server side
// and increases monotonically.
// If the new version is less than the current version, it means that the requested tso service hasn't applied the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about clarifying the source of both the new version and the current version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

// Being merged will cause the group to be removed from this map eventually if the merge is successful.
requestedGroups map[uint32]struct{}

modVersion uint64
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add comments for modVersion uint64.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@bufferflies bufferflies force-pushed the keyspace/version branch 2 times, most recently from d6e0452 to 4234bb8 Compare November 12, 2025 07:42
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Nov 14, 2025

@ystaticy: 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.

@bufferflies
Copy link
Copy Markdown
Contributor Author

/ping @rleungx PTAL again

Signed-off-by: 童剑 <1045931706@qq.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 76.71233% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.45%. Comparing base (d9219d5) to head (a709f84).
⚠️ Report is 70 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9862      +/-   ##
==========================================
- Coverage   78.70%   78.45%   -0.25%     
==========================================
  Files         492      503      +11     
  Lines       66268    67176     +908     
==========================================
+ Hits        52153    52706     +553     
- Misses      10408    10640     +232     
- Partials     3707     3830     +123     
Flag Coverage Δ
unittests 78.45% <76.71%> (-0.25%) ⬇️

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.

@bufferflies bufferflies requested a review from rleungx November 21, 2025 02:49
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 21, 2025

keyspaceID := c.GetKeyspaceID()
var keyspaceGroup *tsopb.KeyspaceGroup
var version uint64
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.

How about unifying the naming, using modRevision and curModRevision?

Signed-off-by: 童剑 <1045931706@qq.com>
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 26, 2025
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Nov 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Nov 27, 2025
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Nov 27, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-11-26 05:11:32.909648438 +0000 UTC m=+679656.558842905: ☑️ agreed by rleungx.
  • 2025-11-27 07:54:33.817140933 +0000 UTC m=+775837.466335390: ☑️ agreed by okJiang.

Signed-off-by: 童剑 <1045931706@qq.com>
@bufferflies
Copy link
Copy Markdown
Contributor Author

/retest

@bufferflies
Copy link
Copy Markdown
Contributor Author

/test pull-unit-test-next-gen

1 similar comment
@bufferflies
Copy link
Copy Markdown
Contributor Author

/test pull-unit-test-next-gen

@ti-chi-bot ti-chi-bot bot merged commit 06ae8ba into tikv:master Nov 28, 2025
56 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cse dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Round-robin updateMember may cause the timestamp to fallback

4 participants