Skip to content

ddl: Fix compatibility with null expression index (#10162)#10174

Merged
ti-chi-bot[bot] merged 3 commits intopingcap:release-7.5from
ti-chi-bot:cherry-pick-10162-to-release-7.5
May 20, 2025
Merged

ddl: Fix compatibility with null expression index (#10162)#10174
ti-chi-bot[bot] merged 3 commits intopingcap:release-7.5from
ti-chi-bot:cherry-pick-10162-to-release-7.5

Conversation

@ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #10162

What problem does this PR solve?

Issue Number: close #9891

Problem Summary:

CREATE TABLE `t` (
  `id` int,
  KEY `idx_name` ((null))
);
alter table t set tiflash replica 1;
insert t values(0);

If the user create an expression index as above, TiDB will generate a "column" for the expression with "Tp": 6. This type of column will generate ColumnNothing which is not expected to be created at the IStorage, thus causing exception thrown during the DDL syncing when TiFlash handling the RaftLog from the table.
Because TiFlash-proxy has persisted the RaftLog but get exception when decoding the RaftLog and apply it to the Storage layer, TiFlash panic.

M(Null, 6, Nil, Nothing) \

static void checkAllTypesAreAllowedInTable(const NamesAndTypesList & names_and_types)
{
for (const auto & elem : names_and_types)
if (elem.type->cannotBeStoredInTables())
throw Exception(
ErrorCodes::DATA_TYPE_CANNOT_BE_USED_IN_TABLES,
"Data type {} cannot be used in tables",
elem.type->getName());
}

What is changed and how it works?

ddl: Fix TiFlash panic when meets expression index with format `((NULL))`
Using `ColumnNothing` in IStorage may bring unexpected behavior when we try to write or read the column. So TiFlash create `ColumnInt8` instead of `ColumnNothing` when `TiDB::ColumnInfo.Tp == Null`.

However, we don't expected the column is used when reading or writing to TiFlash.

* `((null))` is not a normal expression index, this could be created by the user in accident (e.g. executing wrong SQL statement to create the expression index), TiDB should not write or read from it
* Even for normal expression index, TiDB does not use expression when accessing to TiFlash

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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

Fix the issue that TiFlash panic when meets expression index with format `((NULL))`

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@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 Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels May 16, 2025
@ti-chi-bot
Copy link
Member Author

@JaySon-Huang 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.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cherry-pick-approved Cherry pick PR approved by release team. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/cherry-pick-not-approved labels May 16, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
@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 May 19, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang
Copy link
Contributor

/test pull-integration-test

@JaySon-Huang JaySon-Huang removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 19, 2025
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels May 20, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, Lloyd-Pottiger

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [JaySon-Huang,Lloyd-Pottiger]

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 20, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 20, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-05-20 04:50:34.135582214 +0000 UTC m=+64471.236749431: ☑️ agreed by Lloyd-Pottiger.
  • 2025-05-20 07:32:16.532246328 +0000 UTC m=+74173.633413551: ☑️ agreed by JaySon-Huang.

@ti-chi-bot ti-chi-bot bot merged commit bbda147 into pingcap:release-7.5 May 20, 2025
4 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 Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants