The information schema is changed during the execution of the statement

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: Information schema is changed during the execution of the statement

| username: TiDBer_KkruFifg

[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version]
4.0.9

[Reproduction Path] What operations were performed to cause the issue
[Encountered Issue: Issue Phenomenon and Impact]

TiDB version 4.0.9
The business reported that one data entry failed to be written into TiDB, and the business log is as follows:
Error 8028: Information schema is changed during the execution of the statement (for example, table definition may be updated by other DDL ran in parallel). If you see this error often, try increasing tidb_max_delta_schema_count. [try again later] INSERT INTO

According to the SQL information provided by the business, this data was indeed not found in TiDB.
Below are the TiDB logs, with some sensitive information removed.

[2023/01/03 10:03:43.304 +08:00] [WARN] [session.go:488] [“can not retry txn”] [conn=38494744] [label=general] [error=“[domain:8028]Information schema is changed during the execution of the statement (for example, table definition may be updated by other DDL ran in parallel). If you see this error often, try increasing tidb_max_delta_schema_count. [try again later]”] [IsBatchInsert=false] [IsPessimistic=true] [InRestrictedSQL=false] [tidb_retry_limit=3] [tidb_disable_txn_auto_retry=true]

[2023/01/03 10:03:43.304 +08:00] [WARN] [session.go:1123] [“run statement failed”] [conn=38494744] [schemaVersion=1097] [error=“previous statement: INSERT INTO `: [domain:8028]Information schema is changed during the execution of the statement (for example, table definition may be updated by other DDL ran in parallel). If you see this error often, try increasing `tidb_max_delta_schema_count`. [try again later]”]

[2023/01/03 10:03:43.304 +08:00] [INFO] [conn.go:793] [“command dispatched failed”] [conn=38494744] [connInfo=“id:38494744] [command=Query] [status=“inTxn:0, autocommit:1”] [sql=COMMIT] [txn_mode=PESSIMISTIC] [err=”[domain:8028]Information schema is changed during the execution of the statement (for example, table definition may be updated by other DDL ran in parallel). If you see this error often, try increasing tidb_max_delta_schema_count. [try again later]

The current question is
Why didn’t TiDB retry? The official documentation states that this error does not affect the business and will automatically retry?

Explanation:
During the above DML, there was a DDL adding an index to a large table.

[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]

| username: WalterWj | Original post link

Upgrade it. It seems that the new version has metadata locks that can solve similar issues.

| username: TiDBer_KkruFifg | Original post link

Which version should I upgrade to?

| username: WalterWj | Original post link

| username: 我是咖啡哥 | Original post link

In TiDB, changes to metadata objects use an online asynchronous change algorithm. Transactions obtain the corresponding metadata snapshot at the start of execution. If metadata changes occur on the related table during the transaction execution, to ensure data consistency, TiDB will return an Information schema is changed error, causing the user transaction to fail.

To solve this problem, the metadata lock feature was introduced in the online DDL algorithm in TiDB v6.3.0.

v6.3.0 hasn’t been out for long, so upgrading is not very realistic :grinning:

| username: 裤衩儿飞上天 | Original post link

  1. Execute DDL during business off-peak hours as much as possible.
  2. If upgrading, it is recommended to use the LTS version 6.5. However, since it was just released recently, there are still quite a few bugs, so it’s better to wait a bit longer.
| username: TiDBer_KkruFifg | Original post link

Thank you, everyone.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.