Skip to content

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #62979

What problem does this PR solve?

Issue Number: ref #62531, close #63258

Problem Summary:

Previously we have an assumption about "table.Cols()": all public columns are at the front of the array. After #62549, the tombstone columns may stay at the origin place and become non-public during multi-schema change.

It may introduce visible "wrong schema" temporarily:

atler table ... modify column lossy_change_0 ..., add column new_col_0;
[2025/08/18 20:57:23.687 +08:00] [ERROR] [tables.go:186] ["wrong table schema"] [table="{\"id\":6214,\"name\":{\"O\":\"t16db6fde\",\"L\":\"t16db6fde\"},\"charset\":\"utf8mb4\",\"collate\":\"utf8mb4_bin\",\"cols\":[{\"id\":4,\"name\":{\"O\":\"a66d4758\",\"L\":\"a66d4758\"},\"offset\":0,\"origin_default\":null,\"origin_default_bit\":null,\"default\":\"7328359042526431637\",\"default_bit\":null,\"default_is_expr\":false,\"generated_expr_string\":\"\",\"generated_stored\":false,\"dependences\":null,\"type\":{\"Tp\":8,\"Flag\":0,\"Flen\":20,\"Decimal\":0,\"Charset\":\"binary\",\"Collate\":\"binary\",\"Elems\":null,\"ElemsIsBinaryLit\":null,\"Array\":false},\"state\":5,\"comment\":\"\",\"hidden\":false,\"change_state_info\":null,\"version\":2},{\"id\":5,\"name\":{\"O\":\"col2d2b\",\"L\":\"col2d2b\"},\"offset\":1,\"origin_default\":\"jdiefzdyzikac5qtif49xrqj4y7uhz1uqhx9af1hm0nibke78xx0j6xplflf65kjhfsmfb7f0bi23dpcy6q1j23f1uo17ipsbgyp8pl9dn1owdw98t0jzhu\",\"origin_default_bit\":null,\"default\":\"jdiefzdyzikac5qtif49xrqj4y7uhz1uqhx9af1hm0nibke78xx0j6xplflf65kjhfsmfb7f0bi23dpcy6q1j23f1uo17ipsbgyp8pl9dn1owdw98t0jzhu\",\"default_bit\":null,\"default_is_expr\":false,\"generated_expr_string\":\"\",\"generated_stored\":false,\"dependences\":null,\"type\":{\"Tp\":254,\"Flag\":0,\"Flen\":149,\"Decimal\":0,\"Charset\":\"utf8mb4\",\"Collate\":\"utf8mb4_bin\",\"Elems\":null,\"ElemsIsBinaryLit\":null,\"Array\":false},\"state\":3,\"comment\":\"\",\"hidden\":false,\"change_state_info\":null,\"version\":2},{\"id\":7,\"name\":{\"O\":\"col6772\",\"L\":\"col6772\"},\"offset\":3,\"origin_default\":\"xd4core9rklsdxphrcgqrttyr6w7je15bw1hwleb2agyeyz6bm8hadu2oskf1yhmsg48wokqm1b40ro2nyw32wfj\",\"origin_default_bit\":null,\"default\":\"xd4core9rklsdxphrcgqrttyr6w7je15bw1hwleb2agyeyz6bm8hadu2oskf1yhmsg48wokqm1b40ro2nyw32wfj\",\"default_bit\":null,\"default_is_expr\":false,\"generated_expr_string\":\"\",\"generated_stored\":false,\"dependences\":null,\"type\":{\"Tp\":15,\"Flag\":0,\"Flen\":89,\"Decimal\":0,\"Charset\":\"utf8mb4\",\"Collate\":\"utf8mb4_bin\",\"Elems\":null,\"ElemsIsBinaryLit\":null,\"Array\":false},\"state\":3,\"comment\":\"\",\"hidden\":false,\"change_state_info\":null,\"version\":2}],\"index_info\":null,\"constraint_info\":null,\"fk_info\":null,\"state\":5,\"pk_is_handle\":false,\"is_common_handle\":false,\"common_handle_version\":0,\"comment\":\"2fb1e0c6\",\"auto_inc_id\":5308925789339758613,\"auto_id_cache\":0,\"auto_rand_id\":0,\"max_col_id\":7,\"max_idx_id\":0,\"max_fk_id\":0,\"max_cst_id\":0,\"update_timestamp\":460199518172872747,\"ShardRowIDBits\":0,\"max_shard_row_id_bits\":0,\"auto_random_bits\":0,\"auto_random_range_bits\":0,\"pre_split_regions\":0,\"partition\":null,\"compression\":\"\",\"view\":null,\"sequence\":null,\"Lock\":null,\"version\":5,\"tiflash_replica\":null,\"is_columnar\":false,\"temp_table_type\":0,\"cache_table_status\":0,\"policy_ref_info\":null,\"stats_options\":null,\"exchange_partition_info\":null,\"ttl_info\":null,\"revision\":37}"] [column="{\"id\":7,\"name\":{\"O\":\"col6772\",\"L\":\"col6772\"},\"offset\":3,\"origin_default\":\"xd4core9rklsdxphrcgqrttyr6w7je15bw1hwleb2agyeyz6bm8hadu2oskf1yhmsg48wokqm1b40ro2nyw32wfj\",\"origin_default_bit\":null,\"default\":\"xd4core9rklsdxphrcgqrttyr6w7je15bw1hwleb2agyeyz6bm8hadu2oskf1yhmsg48wokqm1b40ro2nyw32wfj\",\"default_bit\":null,\"default_is_expr\":false,\"generated_expr_string\":\"\",\"generated_stored\":false,\"dependences\":null,\"type\":{\"Tp\":15,\"Flag\":0,\"Flen\":89,\"Decimal\":0,\"Charset\":\"utf8mb4\",\"Collate\":\"utf8mb4_bin\",\"Elems\":null,\"ElemsIsBinaryLit\":null,\"Array\":false},\"state\":3,\"comment\":\"\",\"hidden\":false,\"change_state_info\":null,\"version\":2}"] [index=2] [offset=3] [columnNumber=3]

What changed and how does it work?

  • Keep table.Columns order by states during modifying column.

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 added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Sep 1, 2025
@ti-chi-bot
Copy link
Member Author

@tangenta This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

Copy link

ti-chi-bot bot commented Sep 1, 2025

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 1, 2025
Copy link

ti-chi-bot bot commented Sep 1, 2025

[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 d3hunter for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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 the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 1, 2025
Copy link

ti-chi-bot bot commented Sep 1, 2025

@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
pull-unit-test-ddlv1 36e8af6 link true /test pull-unit-test-ddlv1
pull-br-integration-test 36e8af6 link true /test pull-br-integration-test
idc-jenkins-ci-tidb/build 36e8af6 link true /test build
idc-jenkins-ci-tidb/check_dev_2 36e8af6 link true /test check-dev2
idc-jenkins-ci-tidb/check_dev 36e8af6 link true /test check-dev
idc-jenkins-ci-tidb/mysql-test 36e8af6 link true /test mysql-test
idc-jenkins-ci-tidb/unit-test 36e8af6 link true /test unit-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants