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

ddl: check table/database existance using infoschema only #53882

Merged
merged 21 commits into from
Jun 17, 2024

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Jun 7, 2024

What problem does this PR solve?

Issue Number: ref #53246

Problem Summary:

currently we're checking table/database existence using infoschema when its version=latest version, else we will iterating all objects to check, when we run them using multiple threads, it's more likely that its version != latest version, so will go into iterating way.
we don't have a meta kv that can check table/database existence in a fast way, we need iterating all of them and check, it makes table/database creation slower and slower. but we don't need to check it this way, the rationle is:

checking using cached info schema should be enough, as:

  • we will reload schema until success when become the owner, after this PR
  • existing tables are correctly checked in the first place
  • we calculate job dependencies before running jobs, so there will not be 2
    jobs creating same table running concurrently.

if there are 2 owners A and B, we have 2 consecutive jobs J1 and J2 which
are creating the same table T. those 2 jobs might be running concurrently when
A sees J1 first and B sees J2 first. But for B sees J2 first, J1 must already
be done and synced, and been deleted from tidb_ddl_job table, as we are querying
jobs in the order of job id. During syncing J1, B should have synced the schema
with the latest schema version, so when B runs J2, below check will see the table
T already exists, and J2 will fail.

What changed and how does it work?

  • reload info schema when a node become the DDL owner
  • check table/database existence using info schema only

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 release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 7, 2024
Copy link

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

Codecov Report

Attention: Patch coverage is 92.59259% with 6 lines in your changes missing coverage. Please review.

Project coverage is 56.2672%. Comparing base (1870d5f) to head (a99f3e3).
Report is 40 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #53882         +/-   ##
=================================================
- Coverage   74.5995%   56.2672%   -18.3324%     
=================================================
  Files          1508       1638        +130     
  Lines        358344     614091     +255747     
=================================================
+ Hits         267323     345532      +78209     
- Misses        71701     245178     +173477     
- Partials      19320      23381       +4061     
Flag Coverage Δ
integration 36.9325% <84.6153%> (?)
unit 71.5255% <91.3580%> (-1.9614%) ⬇️

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

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

@ti-chi-bot ti-chi-bot bot added the approved label Jun 12, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 12, 2024
Copy link

ti-chi-bot bot commented Jun 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wjhuang2016, zimulala

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 17, 2024
Copy link

ti-chi-bot bot commented Jun 17, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-12 09:26:41.144194586 +0000 UTC m=+543155.197506505: ☑️ agreed by wjhuang2016.
  • 2024-06-17 10:16:15.147864575 +0000 UTC m=+23501.633353407: ☑️ agreed by zimulala.

@ti-chi-bot ti-chi-bot bot merged commit 26d1096 into pingcap:master Jun 17, 2024
23 checks passed
@D3Hunter D3Hunter deleted the existance-check branch June 17, 2024 10:55
@D3Hunter D3Hunter mentioned this pull request Jun 17, 2024
18 tasks
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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants