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) #54576

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. labels Jul 11, 2024
@ti-chi-bot ti-chi-bot added the type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. label Jul 11, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jul 11, 2024
Copy link
Collaborator

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 22, 2024
@tangenta
Copy link
Contributor

/retest

Copy link

ti-chi-bot bot commented Jul 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 22, 2024
Copy link

ti-chi-bot bot commented Jul 22, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-22 03:10:10.653686226 +0000 UTC m=+841832.644627696: ☑️ agreed by Benjamin2037.
  • 2024-07-22 08:52:18.501154527 +0000 UTC m=+862360.492095997: ☑️ agreed by tangenta.

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

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

Please upload report for BASE (release-7.5@b32b212). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.5     #54576   +/-   ##
================================================
  Coverage               ?   71.9974%           
================================================
  Files                  ?       1413           
  Lines                  ?     411606           
  Branches               ?          0           
================================================
  Hits                   ?     296346           
  Misses                 ?      95368           
  Partials               ?      19892           
Flag Coverage Δ
unit 71.9974% <64.1509%> (?)

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

Components Coverage Δ
dumpling 52.9400% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 53.5021% <0.0000%> (?)

@ti-chi-bot ti-chi-bot bot merged commit e0332bf into pingcap:release-7.5 Jul 22, 2024
17 of 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-7.5 This PR is cherry-picked to release-7.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants