Skip to content

[Bug]: [4.2-dev] CREATE INDEX is not serialized with concurrent DML (#29235 not backported) #32244

Closed

Description

@iamlinjunhong

Is there an existing issue for the same bug?

  • I have checked open and closed issues.

#28931 is the existing historical CREATE INDEX/concurrent UPDATE report, fixed on main by #29235. #27487 covers the INSERT metadata-lock mechanism. This item specifically tracks the remaining 4.2-dev backport evaluation, not a claim of a newly reproduced race. No equivalent branch-specific backport tracker was found.

Branch Name

4.2-dev

Commit ID

58edabfe8f9f8a6c126e0634e7246c031a6f0ade (freshly fetched from the upstream remote on 2026-11-05).
Comparison: main 1d51125661c60ff5216c1216a897a3d312875336.

Other Environment Information

Source review of both fixed revisions; isolated local macOS arm64 builds, Go 1.27.1. Local handoff checks used two CN SQL endpoints, one TN and one LogService. No shared test-environment or production mutations were performed.

Actual Behavior

Code-confirmed gap; row loss has not been reproduced on this 4.2-dev revision.

The historical #28931 shows why stale planning/backfill snapshots matter: a successful concurrent UPDATE can be omitted by a successful new index; the unique-index case can publish an incomplete constraint. That historical reproduction is not being attributed to this latest 4.2 revision or to the unresolved old-row cohort under investigation.

Expected Behavior

CREATE INDEX must have a complete handoff with concurrent writers: prior committed writes are visible to backfill; later writes use the newly published index definition or retry. Evaluate backporting the complete main synchronization and snapshot/replan closure, including dependencies and deterministic two-CN coverage.

Steps to Reproduce

There is no fresh failing reproduction for this revision yet. A local bounded check held a writer transaction before CREATE INDEX on another CN, then committed it. INSERT, indexed-column UPDATE, DELETE and non-indexed UPDATE each produced consistent base/hidden-index keys. These four passing schedules do not cover the precise plan-before-commit/barrier window and do not disprove the gap.

Synthetic regression direction:

CREATE TABLE t(id INT PRIMARY KEY, k INT);
INSERT INTO t VALUES (1,10),(2,20);
-- CN2: compile CREATE INDEX ix ON t(k), pause before admission/backfill.
-- CN1: UPDATE t SET k=11 WHERE id=1; commit.
-- CN2: resume CREATE INDEX.
SELECT id,k FROM t IGNORE INDEX(ix) WHERE k=11;
SELECT id,k FROM t FORCE INDEX(ix) WHERE k=11;

Use a deterministic planning barrier, as in main's TestIssue28931StaleUpdatePlanCannotBypassNewIndex; plain simultaneous submission is not an equivalent coverage claim. Also test a conflicting UNIQUE build, both writer/DDL admission orders, and physical hidden-key equality rather than counts alone.

Additional information

Activity

  1. added
    severity/s0
    on Nov 5, 2026
  2. added a commit that references this issue on Nov 11, 2026
    42aac81
  3. Ariznawlll commented on Nov 13, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。本次在已执行的 4.2-dev 并发建索引场景中未复现原 Issue 描述的数据遗漏;旧计划窗口与跨 CN 回归的测试范围及限制如下。

    关键证据

    • 修复 fix: synchronize index builds with concurrent writes on 4.2-dev #32346 合入 4.2-dev。在隔离的 2 CN / 1 TN / 1 LogService 环境验证,首轮两个 CN 的 git_version() 均为 fa67e0ebbee8d6bb66a9d5e87afdd16dac6948ab。原生确定性测试 TestIssue28931StaleUpdatePlanCannotBypassNewIndex 在 race 模式下 10/10 通过,包含普通索引和唯一索引相关子场景;同轮公开 SQL 用例在两个 CN 各运行三次通过。完整运行记录。
    • 最终版 MOTR 回归 PR #331 在 4.2-dev 中注册。其隔离 CI 的两个 CN 均核对为 4.2-dev@2397892f71a937903f72dab41bd2199479102eef,让写事务与 CREATE INDEX 分别走不同 CN,分别测试两个方向各 3 次:观察到 DDL 与写事务重叠后提交 UPDATE、DELETE 和 INSERT,校验基础表完整结果、旧值和新值的强制索引查询、隐藏索引记录的主键,目标步骤 6/6 通过;本轮 race 模式下的原生确定性测试也 10/10 通过,专项 CI 完整通过。本轮运行记录。SQL 重叠不等同于内部旧计划同步点,后者由上述原生测试覆盖。
    • 现有 4.2 每日流水线读取 MOTR 的 4.2-dev 分支并执行已注册的回归;PR 合入后该用例才会进入每日执行,当前尚未合入。

    待解决点

    • 较早的一次测试曾观察到查询端 Error 1176: Key 'ix_payload' doesn't exist;之后的目标测试未再出现,但尚未确认那次错误的根因,不能据此断言其原因已消除。历史记录。
    • 未运行真实混合版本滚动升级,也未在本轮运行完整 4.2 MOTR 套件;以上结论仅覆盖所列测试。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triageseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions