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

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

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@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-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Jun 4, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 4, 2024
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed do-not-merge/cherry-pick-not-approved size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 4, 2024
@lance6716
Copy link
Contributor

please fix the conflict @tangenta

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 7, 2024
@tangenta
Copy link
Contributor

/retest

@tangenta
Copy link
Contributor

/approve

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

/retest

Copy link

codecov bot commented Jun 11, 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-6.5@60b127f). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-6.5     #53774   +/-   ##
================================================
  Coverage               ?   73.6380%           
================================================
  Files                  ?       1096           
  Lines                  ?     352117           
  Branches               ?          0           
================================================
  Hits                   ?     259292           
  Misses                 ?      76156           
  Partials               ?      16669           

@tangenta
Copy link
Contributor

/approve

@ti-chi-bot ti-chi-bot bot added the lgtm label Jun 11, 2024
Copy link

ti-chi-bot bot commented Jun 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [tangenta,wjhuang2016]

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 11, 2024
Copy link

ti-chi-bot bot commented Jun 11, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-11 09:05:54.783169404 +0000 UTC m=+455508.836481531: ☑️ agreed by wjhuang2016.
  • 2024-06-11 17:57:11.804411233 +0000 UTC m=+487385.857723157: ☑️ agreed by tangenta.

@ti-chi-bot ti-chi-bot bot merged commit 88380f9 into pingcap:release-6.5 Jun 11, 2024
10 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-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants