pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.32k stars 5.72k forks source link

ddl: do not reference owner_id for all system DDLs #53355

Closed tangenta closed 2 weeks ago

tangenta commented 2 weeks ago

What problem does this PR solve?

Issue Number: close https://github.com/pingcap/tidb/issues/53327

Problem Summary:

This PR is a patch for #53332.

Except mysql.tidb_mdl_info, there are other system DDLs during upgrade, we should avoid reference owner_id for all of them.

[2024/05/17 10:47:07.637 +08:00] [INFO] [session.go:3894] ["CRUCIAL OPERATION"] [conn=0] [schemaVersion=39] [cur_db=] [sql="ALTER TABLE mysql.stats_meta_history ADD COLUMN IF NOT EXISTS `source` varchar(40) NOT NULL after `version`;"] [user=]
[2024/05/17 10:47:07.717 +08:00] [INFO] [ddl_worker.go:261] ["add DDL jobs"] [category=ddl] ["batch count"=1] [jobs="ID:80, Type:add column, State:queueing, SchemaState:none, SchemaID:1, TableID:64, RowCount:0, ArgLen:4, start time: 2024-05-17 10:47:07.655 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false; "] [table=true]
[2024/05/17 10:47:07.717 +08:00] [INFO] [ddl.go:1181] ["start DDL job"] [category=ddl] [job="ID:80, Type:add column, State:queueing, SchemaState:none, SchemaID:1, TableID:64, RowCount:0, ArgLen:4, start time: 2024-05-17 10:47:07.655 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"] [query="ALTER TABLE mysql.stats_meta_history ADD COLUMN IF NOT EXISTS `source` varchar(40) NOT NULL after `version`;"]
...
[2024/05/17 10:47:08.625 +08:00] [INFO] [ddl_worker.go:1212] ["run DDL job"] [worker="worker 1, tp general"] [category=ddl] [jobID=80] [category=ddl] [job="ID:80, Type:add column, State:queueing, SchemaState:none, SchemaID:1, TableID:64, RowCount:0, ArgLen:0, start time: 2024-05-17 10:47:07.655 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
[2024/05/17 10:47:08.627 +08:00] [INFO] [column.go:135] ["run add column job"] [category=ddl] [job="ID:80, Type:add column, State:running, SchemaState:none, SchemaID:1, TableID:64, RowCount:0, ArgLen:4, start time: 2024-05-17 10:47:07.655 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"] [columnInfo="{\"id\":6,\"name\":{\"O\":\"source\",\"L\":\"source\"},\"offset\":5,\"origin_default\":\"\",\"origin_default_bit\":null,\"default\":null,\"default_bit\":null,\"default_is_expr\":false,\"generated_expr_string\":\"\",\"generated_stored\":false,\"dependences\":null,\"type\":{},\"state\":0,\"comment\":\"\",\"hidden\":false,\"change_state_info\":null,\"version\":2}"]
[2024/05/17 10:47:08.631 +08:00] [INFO] [job_table.go:466] ["handle ddl job failed"] [worker="worker 1, tp general"] [category=ddl] [error="[planner:1054]Unknown column 'owner_id' in 'field list'"] [job="ID:80, Type:add column, State:running, SchemaState:delete only, SchemaID:1, TableID:64, RowCount:0, ArgLen:4, start time: 2024-05-17 10:47:07.655 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"]

What changed and how does it work?

We skip reference owner_id field for all system DDLs.

Check List

Tests

Side effects

Documentation

Release note

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

None
tiprow[bot] commented 2 weeks ago

Hi @tangenta. 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](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 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, 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: - ~~[pkg/ddl/OWNERS](https://github.com/pingcap/tidb/blob/master/pkg/ddl/OWNERS)~~ [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[bot] commented 2 weeks ago

[LGTM Timeline notifier]

Timeline:

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 74.5945%. Comparing base (5d990c6) to head (3ae64a4). Report is 4 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #53355 +/- ## ================================================ + Coverage 72.4968% 74.5945% +2.0976% ================================================ Files 1505 1505 Lines 429835 429931 +96 ================================================ + Hits 311617 320705 +9088 + Misses 98885 89321 -9564 - Partials 19333 19905 +572 ``` | [Flag](https://app.codecov.io/gh/pingcap/tidb/pull/53355/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [integration](https://app.codecov.io/gh/pingcap/tidb/pull/53355/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `49.1705% <100.0000%> (?)` | | | [unit](https://app.codecov.io/gh/pingcap/tidb/pull/53355/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `71.3315% <100.0000%> (-0.0633%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap#carryforward-flags-in-the-pull-request-comment) to find out more. | [Components](https://app.codecov.io/gh/pingcap/tidb/pull/53355/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [dumpling](https://app.codecov.io/gh/pingcap/tidb/pull/53355/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `53.9957% <ø> (ø)` | | | [parser](https://app.codecov.io/gh/pingcap/tidb/pull/53355/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `∅ <ø> (∅)` | | | [br](https://app.codecov.io/gh/pingcap/tidb/pull/53355/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `50.4334% <ø> (+9.0600%)` | :arrow_up: |
tangenta commented 2 weeks ago

/retest

tiprow[bot] commented 2 weeks ago

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

In response to [this](https://github.com/pingcap/tidb/pull/53355#issuecomment-2116964016): >/retest 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.
tangenta commented 2 weeks ago

/retest

tiprow[bot] commented 2 weeks ago

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

In response to [this](https://github.com/pingcap/tidb/pull/53355#issuecomment-2117221341): >/retest 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 commented 2 weeks ago

In response to a cherrypick label: new pull request created to branch release-8.1: #53367.