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: get latest old table ID before replace view (#53720) #55095

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #53720

What problem does this PR solve?

Issue Number: close #53673

Problem Summary:

When we specify OR REPLACE clause in CREATE VIEW statements, if there is an old view, it will be dropped first. However, this old view ID comes from DDL job arguments:

var oldTbInfoID int64

If there are many concurrent CREATE VIEW DDL jobs summiting to the queue, the old view ID maybe outdated. Then we will encounter 'table doesn't exist' error:

tidb/pkg/ddl/table.go

Lines 341 to 344 in 35e09a2

err = t.DropTableOrView(schemaID, job.SchemaName, oldTbInfoID, tbInfo.Name.L)
if err != nil {
job.State = model.JobStateCancelled
return ver, errors.Trace(err)

What changed and how does it work?

Discard the old view ID from DDL job arguments. Always get the latest old view ID.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    Run the script mentioned in issue, and
    mysql> admin show ddl jobs;
    +--------+---------+------------+-------------+--------------+-----------+----------+-----------+----------------------------+----------------------------+----------------------------+--------+
    | JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE    | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME                | START_TIME                 | END_TIME                   | STATE  |
    +--------+---------+------------+-------------+--------------+-----------+----------+-----------+----------------------------+----------------------------+----------------------------+--------+
    |    539 | test    | v          | create view | public       |         2 |      538 |         0 | 2024-05-31 17:10:03.734000 | 2024-05-31 17:10:03.784000 | 2024-05-31 17:10:03.835000 | synced |
    |    537 | test    | v          | create view | public       |         2 |      536 |         0 | 2024-05-31 17:10:03.634000 | 2024-05-31 17:10:03.634000 | 2024-05-31 17:10:03.685000 | synced |
    |    535 | test    | v          | create view | public       |         2 |      534 |         0 | 2024-05-31 17:10:03.485000 | 2024-05-31 17:10:03.535000 | 2024-05-31 17:10:03.585000 | synced |
    
  • 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 added 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. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR. labels Jul 31, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jul 31, 2024
Signed-off-by: lance6716 <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 31, 2024
@lance6716
Copy link
Contributor

/cc @tangenta

@ti-chi-bot ti-chi-bot bot requested a review from tangenta July 31, 2024 09:16
@lance6716
Copy link
Contributor

/retest

1 similar comment
@lance6716
Copy link
Contributor

/retest

Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 62.00000% with 19 lines in your changes missing coverage. Please review.

Please upload report for BASE (release-8.1@fb7dc74). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.1     #55095   +/-   ##
================================================
  Coverage               ?   71.5129%           
================================================
  Files                  ?       1465           
  Lines                  ?     425158           
  Branches               ?          0           
================================================
  Hits                   ?     304043           
  Misses                 ?     100726           
  Partials               ?      20389           
Flag Coverage Δ
unit 71.5129% <62.0000%> (?)

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

Components Coverage Δ
dumpling 53.9957% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 40.9607% <0.0000%> (?)

@lance6716
Copy link
Contributor

/retest

@lance6716
Copy link
Contributor

/build

@lance6716
Copy link
Contributor

/test build

Copy link

tiprow bot commented Aug 1, 2024

@lance6716: No presubmit jobs available for pingcap/[email protected]

In response to this:

/test build

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

ti-chi-bot bot commented Aug 1, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-31 09:16:13.900202632 +0000 UTC m=+347290.180250700: ☑️ agreed by lance6716.
  • 2024-08-01 02:19:24.628181391 +0000 UTC m=+408680.908229460: ☑️ agreed by D3Hunter.

@tangenta
Copy link
Contributor

tangenta commented Aug 1, 2024

/approve

Copy link

ti-chi-bot bot commented Aug 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, 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 1, 2024
@lance6716
Copy link
Contributor

/retest

1 similar comment
@lance6716
Copy link
Contributor

/retest

@ti-chi-bot ti-chi-bot bot merged commit 6d7687a into pingcap:release-8.1 Aug 1, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. 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. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants