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: add WithRefillOption for TableByName and TableByID #55511

Merged
merged 8 commits into from
Aug 20, 2024

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Aug 19, 2024

What problem does this PR solve?

Issue Number: ref #50959

Problem Summary:

What changed and how does it work?

Use context to pass the refill option for TableByName/TableByID

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 do-not-merge/needs-linked-issue 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. sig/planner SIG: Planner labels Aug 19, 2024
Copy link

tiprow bot commented Aug 19, 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 Aug 19, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.3841%. Comparing base (7ef2d46) to head (bae4ec1).
Report is 16 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55511        +/-   ##
================================================
+ Coverage   72.9200%   75.3841%   +2.4640%     
================================================
  Files          1576       1598        +22     
  Lines        440817     450746      +9929     
================================================
+ Hits         321444     339791     +18347     
+ Misses        99599      89699      -9900     
- Partials      19774      21256      +1482     
Flag Coverage Δ
integration 52.0493% <64.0000%> (?)
unit 71.8713% <92.0000%> (-0.1190%) ⬇️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 62.2415% <ø> (+16.2743%) ⬆️

pkg/infoschema/infoschema_v2.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 20, 2024
pkg/infoschema/infoschema_nokit_test.go Outdated Show resolved Hide resolved
@@ -161,8 +161,9 @@ func checkTableForeignKeysValid(sctx sessionctx.Context, is infoschema.InfoSchem
}

referredFKInfos := is.GetTableReferredForeignKeys(schema, tbInfo.Name.L)
ctx := infoschema.WithRefillOption(context.Background(), false)
Copy link
Contributor

Choose a reason for hiding this comment

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

seems it's always false right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we do not fill cache for TableByName in some place like in a loop that may visit a lot tables.

Comment on lines +1474 to +1475
// By default, TableByID does not refill schema cache, and TableByName does.
// The behavior can be changed by providing the context.Context.
Copy link
Contributor

Choose a reason for hiding this comment

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

why we have such a difference?

Copy link
Contributor

Choose a reason for hiding this comment

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

please add this comment to TableByName and TableByID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because when we call TableByID, we need to know the table ID.
And how we know it? usually TableByName is called already.

#55101

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

ti-chi-bot bot commented Aug 20, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-20 04:27:36.849404229 +0000 UTC m=+239651.983854349: ☑️ agreed by lance6716.
  • 2024-08-20 08:09:16.534701411 +0000 UTC m=+252951.669151532: ☑️ agreed by D3Hunter.

Copy link

tiprow bot commented Aug 20, 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 1f5218b 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 Aug 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, hawkingrei, lance6716, tangenta

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 approved label Aug 20, 2024
@ti-chi-bot ti-chi-bot bot merged commit 49828bd into pingcap:master Aug 20, 2024
22 checks passed
@tiancaiamao tiancaiamao deleted the refill-option branch August 20, 2024 12:54
breezewish added a commit that referenced this pull request Aug 21, 2024
…e-upstream

* origin/master:
  parser:  call `SetText` correctly for `CreateViewStmt` (#55520)
  lighting: expose limited fields for `kv.Session` (#55517)
  show: prefilter table name with like pattern and show full tables (#55396)
  Planner: Do not allow cardinality to go below 1 (#55242)
  *: replace maps.Copy which is for map clone with std maps.Clone (#55530)
  infoschema: add WithRefillOption for TableByName and TableByID (#55511)
  domain: change groupSize in splitForConcurrentFetch (#55518)
  ddl: fix resuming to wrong checkpoint when failed during adding index (#55506)
breezewish added a commit to breezewish/tidb that referenced this pull request Aug 21, 2024
…e-upstream

* origin/master:
  parser:  call `SetText` correctly for `CreateViewStmt` (pingcap#55520)
  lighting: expose limited fields for `kv.Session` (pingcap#55517)
  show: prefilter table name with like pattern and show full tables (pingcap#55396)
  Planner: Do not allow cardinality to go below 1 (pingcap#55242)
  *: replace maps.Copy which is for map clone with std maps.Clone (pingcap#55530)
  infoschema: add WithRefillOption for TableByName and TableByID (pingcap#55511)
  domain: change groupSize in splitForConcurrentFetch (pingcap#55518)
  ddl: fix resuming to wrong checkpoint when failed during adding index (pingcap#55506)

Signed-off-by: Wish <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner 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.

5 participants