Information schema is changed during the execution of the statement

【 TiDB 使用环境】生产环境 /测试/ Poc
【 TiDB 版本】
4.0.9

【复现路径】做过哪些操作出现的问题
【遇到的问题:问题现象及影响】

tidb 4.0.9 版本
业务反馈有1条数据写入tidb失败,业务日志如下
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

根据业务提供的sql信息确实没在tidb中查到这条数据
下面是tidb的日志,删除了部分敏感信息

[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]

现在的疑问是
tidb为什么没重试,官方写的这个错误不影响业务,会自动重试?
https://docs.pingcap.com/zh/tidb/stable/sql-faq#触发-information-schema-is-changed-错误的原因

说明:
上述dml期间,有一个大表加索引的ddl

【资源配置】
【附件:截图/日志/监控】

升级吧 好像新版本有元数据锁能解决类似问题。

请问升级到哪个版本?

https://docs.pingcap.com/zh/tidb/dev/metadata-lock

在 TiDB 中,对元数据对象的更改采用的是在线异步变更算法。事务在执行时会获取开始时对应的元数据快照。如果事务执行过程中相关表上发生了元数据的更改,为了保证数据的一致性,TiDB 会返回 Information schema is changed 的错误,导致用户事务提交失败。

为了解决这个问题,在 TiDB v6.3.0 中,online DDL 算法中引入了元数据锁特性。

v6.3.0 没出来多久,升级不太现实 :grinning:

  1. ddl尽量在业务低峰期执行
  2. 如果升级,建议用LTS版本6.5,但是刚发版没多久,bug比较多,还是再等等

多谢各位大佬

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。