pingcap / pingcap/tidb

[ddl] MDL-off ADD INDEX lets concurrent async-commit txn fail with Information schema is changed despite delayForAsyncCommit safe-window protection

Open
#70,030 1 comment 0 reactions 1 assignee Claimed by @wjhuang2016 View on GitHub
affects-7.5 affects-8.1 affects-8.5 component/ddl found-by-ai severity/critical type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

> Evidence status: confirmed.

### 1. Minimal reproduce step (Required)

On testbed 8220955, use the current-master front at 127.0.0.1:14001 (TiDB v9.0.0-beta.2.pre-1895-g5c9198e948) and run go run ./add_index_async_commit_cross_schema_probe.go -dsn root@tcp(127.0.0.1:14001)/ -pause-prewrite=false -hold=0ms -ddl-start-gap=0ms -ddl-kind add-index -txn-kind async-commit -txn-shape basic. With metadata_lock=OFF, the probe logs AFTER_HOLD ddl_status=running and then TXN_RESULT err=Error 8028 Information schema is changed. Control: the same command with -metadata-lock=true succeeds; the probe then runs ADMIN CHECK TABLE plus index/table differential and exact-row oracle expecting rows 1:10 and 2:2. Historical same-day live matrix live-testbed-add-index-async-basic-gap-matrix-mdloff-20260711.log vs ...mdlon... shows 10/10 RED vs 6/6 GREEN across gap 0/1/2/5/10ms.

### 2. What did you expect to see? (Required)

When MDL is OFF, delayForAsyncCommit explicitly promises a SafeWindow+AllowedClockDrift so async commit and 1PC can still commit with the old schema. A plain ADD INDEX in that window should therefore let the transaction commit and preserve the amended index keys, not fail with ErrInfoSchemaChanged.

### 3. What did you see instead? (Required)

The natural same-start MDL-off path returns Error 8028 Information schema is changed while the same probe with MDL ON succeeds and preserves the exact final rowset under ADMIN CHECK TABLE.

### 4. What is your TiDB version? (Required)

TiDB v9.0.0-beta.2.pre-1895-g5c9198e948 MDL-off online ADD INDEX with concurrent async commit

Likely root cause and fix direction

The MDL-off path appears to rely on a stale safe-window contract that the runtime no longer fulfills: delayForAsyncCommit still sleeps before DDL finish, but current transaction setup only wires SchemaLeaseChecker, InfoSchema, EnableAsyncCommit, and Enable1PC, and there is no visible SchemaAmender hookup in TiDB/client-go. The old-schema async-commit transaction therefore appears to hit schema validation instead of being amended/admitted through commit.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.