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

domain,infoschema: make infoschema activity block GC safepoint advancing #58062

Merged
merged 6 commits into from
Dec 9, 2024

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #57952

Problem Summary:

What changed and how does it work?

Currently, when we get a infoschema v2 instance, it's lifetime is in range [ts, ts + 10min)
If the caller hold a infoschema, and use it some time later, it might get error "GC lifetime is shorter than transaction duration" error. That's because infoschema v2 internally use meta package API, while the meta API does not block the GC safepoint advancing.

In this commit, I add a keepAlive() call to the infoschema API,
that keepAlive() function will keep the minimal start ts of active infoschema API calls.

The infosync.Syncer call ReportMinStartTS() periodically, amd now it will take the active infoschema ts into consideration, which is updated by the keepAlive() function.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 6, 2024
Copy link

tiprow bot commented Dec 6, 2024

Hi @tiancaiamao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.0849%. Comparing base (bb9096c) to head (aef6ee9).
Report is 10 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58062        +/-   ##
================================================
+ Coverage   73.1711%   75.0849%   +1.9138%     
================================================
  Files          1674       1720        +46     
  Lines        461507     472153     +10646     
================================================
+ Hits         337690     354516     +16826     
+ Misses       103079      95413      -7666     
- Partials      20738      22224      +1486     
Flag Coverage Δ
integration 49.0231% <100.0000%> (?)
unit 72.3040% <100.0000%> (+0.0068%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 61.5989% <ø> (+15.6156%) ⬆️

@tiancaiamao tiancaiamao requested review from wjhuang2016 and removed request for tangenta December 9, 2024 02:25
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 9, 2024
@tiancaiamao
Copy link
Contributor Author

One possible case that this fix can not cover is that, the caller take an infoschema V2 instance but never use it.
Then keepAlive() is not called.
10min later, infoschema v2 API is called on this is for the first time...

This case is rare and if we found it we can adjust at the caller side, so it should not be a real issue.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 9, 2024
Copy link

ti-chi-bot bot commented Dec 9, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-09 02:59:50.936194742 +0000 UTC m=+234581.024997280: ☑️ agreed by wjhuang2016.
  • 2024-12-09 05:02:50.825493348 +0000 UTC m=+241960.914295890: ☑️ agreed by lcwangchao.

@tiancaiamao
Copy link
Contributor Author

/hold

@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 Dec 9, 2024
// GetAndResetRecentInfoSchemaTS provides the min start ts for infosync.InfoSyncer.
func (h *InfoCache) GetAndResetRecentInfoSchemaTS(now uint64) uint64 {
ret := atomic.LoadUint64(&h.Data.recentMinTS)
atomic.StoreUint64(&h.Data.recentMinTS, now)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use atomic.Uint64 instead?

Copy link
Contributor

@MyonKeminta MyonKeminta Dec 9, 2024

Choose a reason for hiding this comment

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

Is it possible that an infoschemaV2 is acccessed in a lower frequence than ReportMinStartTS, so that a tick of ReportMinStartTS may miss this infoschemaV2 instance, which allows GC to proceed, and then the infoschemaV2 instance becomes unavailable again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory, that is possible, so there is still potential risk. I have discussed that with @lcwangchao
But in practice I think this fix is good enough for the most common cases. @MyonKeminta

Copy link
Contributor

@MyonKeminta MyonKeminta Dec 9, 2024

Choose a reason for hiding this comment

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

Ok. But I suggest these details can be noted in the comments in the code.
Rest LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@tiancaiamao
Copy link
Contributor Author

@MyonKeminta we need some review from the transaction team, PTAL

Copy link

tiprow bot commented Dec 9, 2024

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

Test name Commit Details Required Rerun command
fast_test_tiprow 9f75e35 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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.

Copy link

ti-chi-bot bot commented Dec 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lcwangchao, MyonKeminta, wjhuang2016

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

@tiancaiamao
Copy link
Contributor Author

/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Dec 9, 2024

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test pull-unit-test-ddlv1

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.

@tiancaiamao
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 9, 2024
@ti-chi-bot ti-chi-bot bot merged commit 0ffac36 into pingcap:master Dec 9, 2024
25 checks passed
@tiancaiamao tiancaiamao deleted the issue57952 branch December 9, 2024 12:45
@tiancaiamao tiancaiamao added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Dec 9, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #58103.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. 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.

snapshot infoschema should block GC
5 participants