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

lightning: replace information_schema query when importing table schema with separate show create table #58636

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Dec 31, 2024

What problem does this PR solve?

Issue Number: ref #58141

Problem Summary:

What changed and how does it work?

info schema V2 only store one copy of schema object in memory, so read/write need to lock, if we read too much and takes too long, it affects write, i.e. schema reloading during DDL execution, we can mitigate this by using finer-grained lock, but we cannot avoid it completely with current strategy. so in lightning, we remove related queries, and avoid create table twice by IF NOT EXIST, and check table existence on error by SHOW CREATE TABLE, to make schema import part faster

we also found that the query to information_schema.tables is getting slower over time, and cause lightning dispatch jobs slower, we can fix it too by replace the query.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

import 100K DB and total 200K tables, time reduced from 55m27 -> 19m20

before
image
after
image

  • 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/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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 31, 2024
Copy link

tiprow bot commented Dec 31, 2024

Hi @D3Hunter. 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 31, 2024

Codecov Report

Attention: Patch coverage is 85.10638% with 7 lines in your changes missing coverage. Please review.

Project coverage is 73.7541%. Comparing base (42d4fae) to head (ff0795f).
Report is 20 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58636        +/-   ##
================================================
+ Coverage   73.1093%   73.7541%   +0.6447%     
================================================
  Files          1676       1706        +30     
  Lines        463354     472131      +8777     
================================================
+ Hits         338755     348216      +9461     
+ Misses       103788     102378      -1410     
- Partials      20811      21537       +726     
Flag Coverage Δ
integration 45.6783% <65.9574%> (?)
unit 72.2921% <85.1063%> (-0.0141%) ⬇️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.8023% <ø> (ø)

@D3Hunter D3Hunter changed the title [WIP]lightning: replace information_schema query when importing table schema with separate show create table lightning: replace information_schema query when importing table schema with separate show create table Dec 31, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 31, 2024
@lance6716 lance6716 requested a review from Copilot January 3, 2025 03:04

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 7 changed files in this pull request and generated no comments.

Files not reviewed (5)
  • lightning/tests/lightning_character_sets/run.sh: Language not supported
  • lightning/tests/lightning_no_schema/data/noschema.invalid-schema.sql: Language not supported
  • lightning/tests/lightning_no_schema/data/noschema.invalid.sql: Language not supported
  • lightning/tests/lightning_no_schema/run.sh: Language not supported
  • pkg/lightning/mydump/BUILD.bazel: Language not supported
Comments suppressed due to low confidence (1)

pkg/lightning/mydump/schema_import.go:259

  • Ensure that the new error handling logic in 'runCreateTableJob' and 'runCommonJob' is covered by tests.
func (si *SchemaImporter) runCreateTableJob(ctx context.Context, p *parser.Parser, job *schemaJob) error {
"github.com/pingcap/errors"
"github.com/pingcap/tidb/br/pkg/storage"
tmysql "github.com/pingcap/tidb/pkg/errno"
Copy link
Contributor

Choose a reason for hiding this comment

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

the package name errno is enough

Copy link

ti-chi-bot bot commented Jan 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716

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 approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 3, 2025
Copy link

ti-chi-bot bot commented Jan 3, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-03 03:22:42.95985695 +0000 UTC m=+666298.315861491: ☑️ agreed by lance6716.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. 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.

2 participants