Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gc: Implement compatibility methods and GetAllKeyspacesGCStates method to GCStateManager #9134

Open
wants to merge 56 commits into
base: master
Choose a base branch
from

Conversation

MyonKeminta
Copy link
Contributor

@MyonKeminta MyonKeminta commented Mar 11, 2025

What problem does this PR solve?

Issue Number: Ref #8978

What is changed and how does it work?

Implement compatibility methods and `GetAllKeyspacesGCStates` method to `GCStateManager`, which is planned to be the replacement of `SafePointManager`.

Blocked by:

This PR is branched from #9109 which is not merged yet. If you want to view the diff in this PR without being disturbed by changes from #9109, please see: MyonKeminta/pd@m/gc-state-storage...MyonKeminta:pd:m/gc-state-manager

Part of this PR is split out to #9169 . Please merge #9169 first. To see changes in this PR based on #9169, see: MyonKeminta/pd@m/gc-state-manager-partial...MyonKeminta:pd:m/gc-state-manager

Check List

Tests

  • Unit test

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity

Related changes

Release note

None.

Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Copy link
Contributor

ti-chi-bot bot commented Mar 11, 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 release-note-none Denotes a PR that doesn't merit a release note. 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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 11, 2025
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 77.85235% with 33 lines in your changes missing coverage. Please review.

Project coverage is 75.79%. Comparing base (9092ccc) to head (e978f22).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9134      +/-   ##
==========================================
+ Coverage   75.72%   75.79%   +0.06%     
==========================================
  Files         477      477              
  Lines       73437    73584     +147     
==========================================
+ Hits        55612    55773     +161     
+ Misses      14342    14331      -11     
+ Partials     3483     3480       -3     
Flag Coverage Δ
unittests 75.79% <77.85%> (+0.06%) ⬆️

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.

@MyonKeminta MyonKeminta changed the title gc: Add GCStateManager which is planned to be the replacement of SafePointManager. gc: Add GCStateManager which is planned to be the replacement of SafePointManager Mar 11, 2025
@MyonKeminta MyonKeminta mentioned this pull request Mar 11, 2025
17 tasks
@MyonKeminta MyonKeminta marked this pull request as ready for review April 8, 2025 06:06
@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 Apr 8, 2025
Signed-off-by: MyonKeminta <[email protected]>
Copy link
Contributor

ti-chi-bot bot commented Apr 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JmPotato

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 9, 2025
Copy link
Contributor

ti-chi-bot bot commented Apr 9, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-09 07:51:27.572139062 +0000 UTC m=+2242781.256375158: ☑️ agreed by JmPotato.

@ti-chi-bot ti-chi-bot bot added the approved label Apr 9, 2025
Signed-off-by: MyonKeminta <[email protected]>
@@ -194,9 +218,23 @@ func (m *GCStateManager) advanceGCSafePointImpl(keyspaceID uint32, target uint64
return wb.SetGCSafePoint(keyspaceID, target)
})
if err != nil {
log.Error("failed to advance GC safe point",
zap.Uint32("keyspace-idD", keyspaceID),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
zap.Uint32("keyspace-idD", keyspaceID),
zap.Uint32("keyspace-id", keyspaceID),


// saturatingDuration returns a duration calculated by multiplying the given `ratio` and `base`, truncated within the
// range [0, math.MaxInt64] to avoid negative value and overflowing.
func saturatingDuration(ratio int64, base time.Duration) time.Duration {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used for avoiding overflow after multiplication, so that it prevents the user from specifying a too large value and causing undefined behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Btw I renamed it to saturatingMultiplyDuration

Copy link
Member

Choose a reason for hiding this comment

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

Will it cover up mistakes? BTW, we have enabled durationcheck linter.

}
if res.NewTxnSafePoint != newServiceSafePoint {
minServiceSafePoint = &endpoint.ServiceSafePoint{
ServiceID: "__pseudo_service:" + res.BlockerDescription,
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to unify the format of ServiceID? __pseudo_service: TiDBMinStartTS { Key: %+q, MinStartTS: %d } looks wired.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any suggestion?

@MyonKeminta
Copy link
Contributor Author

/hold
Some details still need discussion.

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. 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.

3 participants