pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.37k stars 5.86k forks source link

infoschema, meta: fix wrong auto id after `rename table` (#55847) #57572

Closed ti-chi-bot closed 4 days ago

ti-chi-bot commented 4 days ago

This is an automated cherry-pick of #55847

What problem does this PR solve?

Issue Number: close #55846 #53329

Problem Summary:

What changed and how does it work?

In the previous logic, rename table will reuse the old Allocator.

For the first case in the issue, drop database will clear all related meta data with old schema. So the next call of rebase4Signed will allocate ids from 0.

For the second case, after infoschema reload, the Allocator created in loadTableInfo will allocate id starting from 0, which may generate duplicated keys.

This affects both v1 and v2.

To solve these problem, old meta will be copied for new table after rename table. So new table will never get an already allocated id.

Check List

Tests

Side effects

Documentation

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None
ti-chi-bot[bot] commented 4 days ago

This cherry pick PR is for a release branch and has not yet been approved by triage owners. Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be approved by the approvers firstly.
  2. AFTER it has been approved by approvers, please wait for the cherry-pick merging approval from triage owners.
Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
ti-chi-bot[bot] commented 4 days ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign wjhuang2016 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/pingcap/tidb/blob/release-8.5/OWNERS)** - **[pkg/meta/OWNERS](https://github.com/pingcap/tidb/blob/release-8.5/pkg/meta/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
tiancaiamao commented 4 days ago

It's in v8.5 already, so no need to cherry-pick.

ti-chi-bot[bot] commented 4 days ago

@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/build ae50d72a9ed021afca889bcdf6a5a9a30a63c8e6 link true /test build
idc-jenkins-ci-tidb/check_dev_2 ae50d72a9ed021afca889bcdf6a5a9a30a63c8e6 link true /test check-dev2
idc-jenkins-ci-tidb/unit-test ae50d72a9ed021afca889bcdf6a5a9a30a63c8e6 link true /test unit-test
pull-unit-test-ddlv1 ae50d72a9ed021afca889bcdf6a5a9a30a63c8e6 link true /test pull-unit-test-ddlv1
idc-jenkins-ci-tidb/check_dev ae50d72a9ed021afca889bcdf6a5a9a30a63c8e6 link true /test check-dev
idc-jenkins-ci-tidb/mysql-test ae50d72a9ed021afca889bcdf6a5a9a30a63c8e6 link true /test mysql-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).