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

*: add context.Context parameter to infoschema TableByName #54479

Merged
merged 8 commits into from
Jul 9, 2024

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #50959

Problem Summary:

What changed and how does it work?

In infoschema v1, all schema meta are in-memory, so TableByName are fast enough.
In infoschema v2, there may be cache miss and loading from remote network, that could be slower.

Add a context.Context parameter so it is easier to trace and debug the cache miss cases.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
curl http://127.0.0.1:10080/debug/pprof/trace?seconds=3s > trace.out
go tool trace -http=:6060 trace.out

The API responsive duration distribution:

image

The execute trace of TableByName:

image

With those trace information, we can analyze the reason of some of the p999 slowness.

  • 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 release-note-none sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 5, 2024
Copy link

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

Codecov Report

Attention: Patch coverage is 95.23810% with 9 lines in your changes missing coverage. Please review.

Project coverage is 57.0108%. Comparing base (49f1427) to head (d170390).
Report is 12 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54479         +/-   ##
=================================================
- Coverage   74.7101%   57.0108%   -17.6994%     
=================================================
  Files          1545       1692        +147     
  Lines        362047     619328     +257281     
=================================================
+ Hits         270486     353084      +82598     
- Misses        71923     241912     +169989     
- Partials      19638      24332       +4694     
Flag Coverage Δ
integration 39.6894% <72.4867%> (?)
unit 72.0615% <91.0052%> (-1.5597%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (-2.2339%) ⬇️
parser ∅ <ø> (∅)
br 62.9004% <100.0000%> (+15.2190%) ⬆️

@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 5, 2024
Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

Using Context.Background() doesn't make thing worse so LGTM. And I hope we can use correct context in this PR or the following PR.

br/pkg/restore/log_client/client.go Outdated Show resolved Hide resolved
pkg/ddl/ddl_api.go Outdated Show resolved Hide resolved
pkg/ddl/foreign_key.go Outdated Show resolved Hide resolved
pkg/domain/extract.go Outdated Show resolved Hide resolved
@@ -157,7 +157,7 @@ func (tne *tableNameExtractor) handleIsView(t *ast.TableName) (bool, error) {
if !isView {
return false, nil
}
viewTbl, err := tne.is.TableByName(schema, table)
viewTbl, err := tne.is.TableByName(context.Background(), schema, table)
Copy link
Contributor

Choose a reason for hiding this comment

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

receiver has ctx

@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 8, 2024
Copy link

ti-chi-bot bot commented Jul 9, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-08 02:23:12.796316699 +0000 UTC m=+237890.031550811: ☑️ agreed by lance6716.
  • 2024-07-09 08:31:22.460075793 +0000 UTC m=+346379.695309910: ☑️ agreed by tangenta.

Copy link

tiprow bot commented Jul 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 d170390 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
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jul 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, AilinKid, bb7133, lance6716, tangenta, XuHuaiyu

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 Jul 9, 2024
@tiancaiamao
Copy link
Contributor Author

/test pull-lightning-integration-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 pull-lightning-integration-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.

@lance6716
Copy link
Contributor

/retest

Copy link

tiprow bot commented Jul 9, 2024

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

In response to this:

/retest

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

ti-chi-bot bot commented Jul 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
idc-jenkins-ci-tidb/check_dev_2 d170390 link unknown /test check-dev2

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/test-infra repository. I understand the commands that are listed here.

@tiancaiamao
Copy link
Contributor Author

/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 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 merged commit f490a98 into pingcap:master Jul 9, 2024
31 of 33 checks passed
@tiancaiamao tiancaiamao deleted the trace branch July 10, 2024 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none sig/planner SIG: Planner 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.

None yet

7 participants