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

infoschema: tend to cache the old key in caching strategy for infoschema v2 #54501

Merged
merged 7 commits into from
Jul 11, 2024

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #54500
ref #50959

Problem Summary:

What changed and how does it work?

The bug is caused by the old caching strategy.
When we check the schema version from the btree, we get the old cache key.
When we update the cache, we use the latest schema version as the cache key.
It means when the old cache key is evicted, we will always cache miss and the refill does not help.

In this commit, I change the caching strategy tending to cache the old schema version.

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
@tiancaiamao tiancaiamao requested a review from GMHDBJD July 8, 2024 10:00
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 8, 2024
@tiancaiamao tiancaiamao requested a review from D3Hunter July 8, 2024 10:01
Copy link

tiprow bot commented Jul 8, 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 Jul 8, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 56.2954%. Comparing base (749d303) to head (6428767).

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54501         +/-   ##
=================================================
- Coverage   74.8681%   56.2954%   -18.5727%     
=================================================
  Files          1549       1665        +116     
  Lines        362122     604095     +241973     
=================================================
+ Hits         271114     340078      +68964     
- Misses        71466     240690     +169224     
- Partials      19542      23327       +3785     
Flag Coverage Δ
integration 37.0036% <14.2857%> (?)
unit 71.7947% <85.7142%> (-2.0010%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (-2.2339%) ⬇️
parser ∅ <ø> (∅)
br 52.5794% <ø> (+4.9011%) ⬆️
Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor Author

/retest-required

Copy link

tiprow bot commented Jul 8, 2024

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

In response to this:

/retest-required

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
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

rest lgtm

pkg/infoschema/infoschema_v2.go Outdated Show resolved Hide resolved
@@ -444,6 +440,17 @@ func isSpecialDB(dbName string) bool {
dbName == util.MetricSchemaName.L
}

// EvictTable is exported for testing only.
func (is *infoschemaV2) EvictTable(schema, tbl string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe implement it in test file of the same package, see

func (sm *Manager) GetRunningTaskCnt() int {
return sm.getSchedulerCount()
}
// DelRunningTask implements Scheduler.DelRunningTask interface.
func (sm *Manager) DelRunningTask(id int64) {
sm.delScheduler(id)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some other parts may also need this functionality and it's in some other packages.
https://github.com/pingcap/tidb/pull/54479/files#diff-cabf59f012600c8b513d4eb03385f48e3fdd9b8ac3f13c175133d40c9354722bR279

pkg/infoschema/test/infoschemav2test/v2_test.go Outdated Show resolved Hide resolved
Copy link

ti-chi-bot bot commented Jul 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, GMHDBJD

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

Copy link

ti-chi-bot bot commented Jul 9, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-08 12:13:54.494152918 +0000 UTC m=+273331.729387030: ☑️ agreed by GMHDBJD.
  • 2024-07-09 07:15:22.506371333 +0000 UTC m=+341819.741605438: ☑️ agreed by D3Hunter.
@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Jul 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 unit-test

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

/test mysql-test
/test check-dev2

Copy link

tiprow bot commented Jul 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 mysql-test
/test check-dev2

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 9, 2024
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 10, 2024
@tiancaiamao
Copy link
Contributor Author

/test mysql-test
/test check-dev2

Copy link

tiprow bot commented Jul 10, 2024

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

In response to this:

/test mysql-test
/test check-dev2

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

/test mysql-test
/test check-dev2

Copy link

tiprow bot commented Jul 10, 2024

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

In response to this:

/test mysql-test
/test check-dev2

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

/ok-to-test

@tiancaiamao
Copy link
Contributor Author

Need to wait this PR to merge first #54282
The mysql-test has been merged, and that one is merging, so in the meantime the CI for master branch would fail temporarily

@tiancaiamao
Copy link
Contributor Author

/test mysql-test
/test check-dev2

Copy link

tiprow bot commented Jul 10, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test mysql-test
/test check-dev2

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

/test mysql-test

Copy link

tiprow bot commented Jul 11, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test mysql-test

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

/test check-dev2

Copy link

tiprow bot commented Jul 11, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

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

/retest

@ti-chi-bot ti-chi-bot bot merged commit 05c8119 into pingcap:master Jul 11, 2024
23 checks passed
@tiancaiamao tiancaiamao deleted the cache-strategy branch July 11, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test release-note-none size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
3 participants