-
Notifications
You must be signed in to change notification settings - Fork 6k
infoschema: fix issue of load multiple schema diff at a time will cause information schema cache miss #53620
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: crazycs520 <[email protected]>
…se information schema cache miss Signed-off-by: crazycs520 <[email protected]>
Skipping CI for Draft Pull Request. |
Hi @crazycs520. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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. |
Signed-off-by: crazycs520 <[email protected]>
Signed-off-by: crazycs520 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #53620 +/- ##
================================================
+ Coverage 72.4357% 75.1719% +2.7361%
================================================
Files 1507 1510 +3
Lines 430587 434170 +3583
================================================
+ Hits 311899 326374 +14475
+ Misses 99369 87334 -12035
- Partials 19319 20462 +1143
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Signed-off-by: crazycs520 <[email protected]>
if i != len(diffs)-1 { | ||
// If load multiple schema diffs, we need to insert each schema version into cache, | ||
// to make sure the schema version in cache is continuous, otherwise the cache will have holes, | ||
// then stale-read query will meet schema cache miss, then load snapshot schema from TiKV, | ||
// then the TiKV which store schema will become the hot spot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might make create table/database(say 1M tables) or maintainance while customer might execute many DDLs, much slower, and might takes more memory, we need more test on it.
stale read does NOT always exist in customer scenarios, and even it exist, in this case we should load those schema meta on demand, during the load phase the QPS might be lower, but after that, it's ok, i think it's acceptable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He is fixing infoschema v1, FYI @D3Hunter
/hold need discuss memory footprint/DDL performance of this change, evalulate whether it's necessary to change it. |
actions := make([]uint64, 0, len(diffs)) | ||
diffTypes := make([]string, 0, len(diffs)) | ||
for _, diff := range diffs { | ||
for i, diff := range diffs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not wrap the content of the old for loop as a function, and call them len(diffs)-1 times?
Like:
for _, diff := range diffs {
builder := NewBuilder()
builder.ApplyDiff()
builder.Build() // or BuildWithoutUpdateBundle
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more complicated to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. split the code into small functions improves the readibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't need multiple builders here, maybe it's better to extract a infoschema.clone
function to use in here.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tiancaiamao The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
PR needs rebase. 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. |
@crazycs520: The following tests failed, say
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. |
What problem does this PR solve?
Issue Number: close #53428
Problem Summary: This PR fix the situation mentioned #53428 (comment)
fix issue of load multiple schema diff at a time will cause information schema cache miss, then may cause stale-read query latency 10x spike.
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.