Skip to content

meta: fix incorrect foreign key field init in table info clone #60103

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

Merged
merged 6 commits into from
Mar 17, 2025

Conversation

River2000i
Copy link
Contributor

@River2000i River2000i commented Mar 17, 2025

What problem does this PR solve?

Issue Number: close #60044

Problem Summary: br restroe table will clone table info before create table, it will meet the incorrect null foreign key field init. Fix incorrect load foreign key init in tableInfo.Clone() because of make([]*FKInfo, len(t.ForeignKeys))

What changed and how does it work?

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 do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 17, 2025
@River2000i
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Mar 17, 2025
Copy link

ti-chi-bot bot commented Mar 17, 2025

Hi @River2000i. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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

tiprow bot commented Mar 17, 2025

Hi @River2000i. 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

ti-chi-bot bot commented Mar 17, 2025

@River2000i: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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.

1 similar comment
Copy link

tiprow bot commented Mar 17, 2025

@River2000i: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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.

@River2000i River2000i changed the title [WIP]meta: tableinfo not need to clone foreighn key [WIP]meta: tableinfo not need to clone foreign key Mar 17, 2025
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 17, 2025
@River2000i River2000i changed the title [WIP]meta: tableinfo not need to clone foreign key meta: clone table info not need to new foreign keys Mar 17, 2025
@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 Mar 17, 2025
@River2000i River2000i changed the title meta: clone table info not need to new foreign keys meta: clone table info with new foreign keys when not nil Mar 17, 2025
Copy link
Contributor

@Leavrth Leavrth left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -242,7 +242,13 @@ func (t *TableInfo) Clone() *TableInfo {
nt := *t
nt.Columns = make([]*ColumnInfo, len(t.Columns))
nt.Indices = make([]*IndexInfo, len(t.Indices))
nt.ForeignKeys = make([]*FKInfo, len(t.ForeignKeys))

if t.ForeignKeys != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe need to set nt.ForeignKeys = nil if t.ForeignKeys is []*FKInfo{}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

default ForeignKeys is nil, seems it's not necessary check nil or len(0)🤔
https://github.com/pingcap/tidb/blob/master/pkg/ddl/create_table.go#L1219-L1224

@GMHDBJD PTAL~

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm worried about if the tableInfo is from the old version. For example, it is from backup or the cluster origin data after tidb upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, we can unify nil and len(0) into nil in clone.

@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Mar 17, 2025
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.8196%. Comparing base (77f118f) to head (49d43e5).
Report is 9 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #60103        +/-   ##
================================================
+ Coverage   73.1493%   73.8196%   +0.6702%     
================================================
  Files          1706       1707         +1     
  Lines        471415     473576      +2161     
================================================
+ Hits         344837     349592      +4755     
+ Misses       105415     102883      -2532     
+ Partials      21163      21101        -62     
Flag Coverage Δ
integration 43.0417% <100.0000%> (?)
unit 72.5705% <100.0000%> (+0.2353%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 47.3161% <ø> (+0.0980%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@River2000i River2000i requested a review from Leavrth March 17, 2025 08:09
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 17, 2025
Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Mar 17, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, Leavrth

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

ti-chi-bot bot commented Mar 17, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-17 08:10:28.149290085 +0000 UTC m=+256721.833526165: ☑️ agreed by Leavrth.
  • 2025-03-17 08:15:26.895293501 +0000 UTC m=+257020.579529597: ☑️ agreed by GMHDBJD.

@River2000i River2000i changed the title meta: clone table info with new foreign keys when not nil meta: clone table info with new foreign keys default to nil Mar 17, 2025
@River2000i
Copy link
Contributor Author

/retest

2 similar comments
@River2000i
Copy link
Contributor Author

/retest

@River2000i
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit c508e4b into pingcap:master Mar 17, 2025
25 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-9.0-beta.1: #60129.

@River2000i River2000i changed the title meta: clone table info with new foreign keys default to nil meta: fix incorrect foreign key field init in table info clone Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-9.0-beta.1 ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

infoschema v2 loads all the tables when starts
5 participants