Skip to content

[Bug]: 500 concurrent DATA BRANCH schema operations hit SNAPSHOT lock timeouts and lose connections #29208

Open

Description

@daviszhen

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Related issues:

This report provides a separate high-concurrency DATA BRANCH workload reproduction. Please triage whether it is the same global SNAPSHOT/lineage gate mechanism or a distinct failure in the DATA BRANCH table-branch path.

Branch Name

main (tested at the detached commit below)

Commit ID

77dbf54

Other Environment Information

Workload parameters:

  • backend: MatrixOne
  • workflow: software_dev
  • workers: 500 concurrent workers
  • steps per worker: 20
  • fixture: 250,000 rows
  • total planned steps: 10,000
  • per-command timeout: 120 seconds
  • workload timeout: 7,200 seconds

Actual Behavior

The workload failed under 500 concurrent workers:

  • 301/500 workers completed.
  • 199/500 workers failed.
  • 6,812 steps completed; 199 steps failed as the first failed step of a worker.
  • 172 worker failures returned MySQL error 1205: Lock wait timeout exceeded; try restarting transaction.
  • 27 worker failures returned MySQL error 2013: Lost connection to MySQL server during query (timed out).
  • No worker was classified as a benchmark timeout; the failures came from MatrixOne SQL execution.
  • The workload wall-clock time was 4,659.55 seconds (about 77 minutes 40 seconds).

The client-visible user statement was an ALTER on an otherwise independent branch table, for example:

ALTER TABLE g4d_s_35580702311_1_258_10
  ADD COLUMN g4d_tier_258_10 BIGINT;

The MatrixOne server log shows the same failures returning from the internal SNAPSHOT feature-registry update:

UPDATE mo_catalog.mo_feature_registry
SET scope_spec = scope_spec, updated_at = updated_at
WHERE feature_code = 'SNAPSHOT';

Representative server log entries are from compile/sql_executor.go:201 and frontend/session.go:4065:

Lock wait timeout exceeded; try restarting transaction
query trace status:
  statement: ALTER TABLE g4d_s_... ADD COLUMN g4d_tier_... BIGINT
  error: Lock wait timeout exceeded; try restarting transaction

The server log also contains repeated:

txn need retry in rc mode, def changed

and, during the long tail:

internal error: iscp transaction finish timeout

The workload uses independent worker IDs, branch/table names, and row IDs. It does not intentionally update the same user row across workers. The contention is therefore in the DATA BRANCH/DDL/catalog lifecycle path rather than an application-level row conflict.

Controls on the same host and commit passed:

  • MatrixOne software_dev, 10 workers: 200/200 steps, 0 failures.
  • MatrixOne software_dev, 100 workers: 2,000/2,000 steps, 0 failures.
  • MatrixOne software_dev, 500 workers: 6,812 completed steps and 199 failed workers.

P0-4 did not show an OOM or host resource exhaustion:

  • runtime samples: 368
  • peak host memory used: 131,768,860,672 bytes
  • maximum observed container CPU: 878.27%
  • maximum host load1: 14.57
  • database storage after workload: 19,258,696,936 bytes

Expected Behavior

Independent DATA BRANCH/ALTER operations should either complete or return a controlled, retryable result under high concurrency. They should not cause a large fraction of workers to fail with generic lock wait timeouts and lost client connections.

If a global SNAPSHOT/lineage coordination gate is required for correctness, the implementation should avoid holding an overly broad critical section for unrelated branch operations, or provide a safe internal retry/backoff path that does not turn contention into connection loss.

Steps to Reproduce

  1. Build and start MatrixOne from commit 77dbf54.
  2. Prepare a database with a base table containing 250,000 rows:
CREATE DATABASE git4data;
USE git4data;

CREATE TABLE g4d_base (
  id BIGINT PRIMARY KEY,
  c_value BIGINT NOT NULL,
  c_status VARCHAR(16) NOT NULL,
  c_score DECIMAL(18,4) NOT NULL
);
  1. Run the deterministic Git4Data harness with 500 concurrent workers:
GIT4DATA_MATRIXONE_HOST=127.0.0.1 \
GIT4DATA_MATRIXONE_PORT=6001 \
GIT4DATA_MATRIXONE_USER=root \
GIT4DATA_MATRIXONE_PASSWORD=111 \
GIT4DATA_MATRIXONE_DATABASE=git4data \
python3 -m git4data.runner \
  --backend matrixone \
  --workflow software_dev \
  --workers 500 \
  --steps 20 \
  --rows 250000 \
  --timeout-seconds 7200 \
  --command-timeout-seconds 120 \
  --base-table g4d_base \
  --output /tmp/git4data-matrixone-500/run-summary.json

Each worker performs an independent sequence equivalent to:

data branch create table <agent_branch> from g4d_base;
data branch create table <step_branch> from <parent_branch>;
ALTER TABLE <step_branch> ADD COLUMN <worker_step_column> BIGINT;
UPDATE <step_branch> SET <worker_step_column> = ... WHERE id = ...;
SELECT COUNT(*) ...;
SELECT SUM(...) ...;
data branch merge <step_branch> into <parent_branch> when conflict accept;
data branch delete table <step_branch>;

The exact workload source is in the benchmark repository:
https://github.com/matrixorigin/mo-benchmark/tree/codex/p0-2-git4data-concurrency/git4data

Additional information

The 100-worker control completes successfully, while the 500-worker run crosses a sharp concurrency boundary. The failure is not a GitHub Actions timeout: the runner remained alive, collected P0-4 data, and uploaded the artifact.

The main diagnostic question is whether the internal UPDATE of mo_catalog.mo_feature_registry for feature_code SNAPSHOT is a global lifecycle gate for every branch ALTER/copy operation, and whether concurrent DATA BRANCH create/merge/delete operations can hold related catalog/lineage locks long enough to starve other ALTER transactions.

No data corruption was observed. The workflow cleaned up the service after collecting logs and resource data.

Activity

  1. added
    kind/bug
    on Sep 21, 2026
  2. daviszhen commented on Sep 21, 2026

    @daviszhen
    ContributorAuthor

    Additional reproduction from Git4Data P0-2:

    The runner is correctly marked failed because failed workers are non-zero, even though the step completion rate was 99.94%.

  3. daviszhen commented on Sep 21, 2026

    @daviszhen
    ContributorAuthor

    Additional reproduction: MatrixOne mcts at 500 workers.

    This is a third workflow-level reproduction of the same global SNAPSHOT lock contention. It is more severe than software_dev and data_cleaning at 500 workers because the mcts workload runs 100 steps per worker and reaches the workload timeout.

  4. added
    severity/s0
    ai-easy
    and removed on Sep 24, 2026
  5. gouhongshen commented on Oct 9, 2026

    @gouhongshen
    Contributor

    PR #29798 is trying to fix this issue.

  6. gouhongshen commented on Oct 18, 2026

    @gouhongshen
    Contributor

    PR #29798 has merged and is awaiting manual validation. The issue remains open.

  7. added and removed
    severity/s0
    on Oct 22, 2026
  8. Ariznawlll commented on Oct 27, 2026

    @Ariznawlll
    Collaborator

    测试补充:原始 500 并发重跑与 DELETE 回滚 / 新事务重试核验

    本条汇总已经执行的两轮不同范围的测试,不把小规模专项通过等同于原 500 并发场景验收完成。

    测试版本

    • 原始 software_dev 重跑:官方 main 533e95796177d9eacdc909059ccf72b7ddd3ba5f,run 40466369540 attempt 2。
    • DELETE 专项:官方 main baa83f4b96e56ec214f92c68f7b56539b9e0fa45,run 40470513056 attempt 1,harness e4c706571cc38716b06569160cc0341b2d92a52c。
    • mo-srv-129 上 workflow-owned 的隔离 MatrixOne 容器;这是共享主机,不等同于原报告独占环境,不作性能同比结论。两轮产品 SHA、数据量及 fixture 不同。

    原问题验证

    原始 software_dev 为 500 workers × 20 steps、250,000 行,未修改原 workload、未加入隐藏重试。运行约 252.19 秒,500 个 worker 全部在 step 0 的 DATA BRANCH DELETE TABLE 返回 20706: lock options conflict, wait policy is fast fail,完成步骤 0/10,000。不能把已经执行 fork/mutate/merge 或 evaluation 查询等同于完整 step 已完成。

    这一轮客户端汇总不再是原报告的 1205/2013,而是快速失败 20706;这说明失败形态发生变化,不足以单独证明原并发工作流已经正常,也不能仅凭 20706 就另提“数据损坏”问题。

    Happy Path 覆盖

    后续 DELETE 专项使用新建 100 行 fixture,129/129 组满足断言:

    • 无 ALTER / 有 ALTER 后的 branch create → mutate → merge → delete,各 3 轮。
    • 显式事务正常提交 3 轮,同时校验事务内 probe 写入确实提交。
    • 真实持有 SNAPSHOT shared gate 的冲突组 20 轮,autocommit / explicit 各 10 轮。
    • 10 个并发 DELETE × 10 轮,共 100 组。

    共 113 次首次操作返回 20706;释放冲突或等待该轮其他初始操作结束后,113/113 在新连接的新事务中第一次重试 DELETE 成功。没有用 DROP TABLE 替代 DELETE 计作成功。其余 16 次首次即成功。

    Unhappy Path 覆盖

    • 113 次快速失败全部核对失败前后的 base / parent / child 完整行、DDL、table ID、对应 branch metadata 与快照信息一致。
    • 通过独立观察连接,在失败客户端主动 rollback/close 之前读取上述状态,113/113 与基线一致;不是靠测试侧先 rollback 再声称服务端已原子失败。
    • 10 次显式事务冲突中,失败前先写 txn_probe,错误后再发 COMMIT,独立连接看到 probe 行数为 0,验证没有提交失败事务的前置写入。
    • 重试成功后 child 不存在,base/parent 完整数据及定义不变;测试库清理完成。

    白盒验证

    这是公开 SQL 的黑盒专项,持锁连接以 SELECT ... FOR SHARE 制造确定性真实冲突,没有修改产品二进制或注入假错误。本次核对了驱动的状态比较、重试和显式事务断言;未新增执行 UT/race。

    重要限制:并发重试是在初始竞争操作结束后执行,不能证明持续 500 并发下的重试吞吐、饥饿或尾延迟。专项使用新 fixture,不能倒推此前已清理容器内每一个失败分支都已被逐项验证。

    回归测试

    原始 Git4Data runner 的 DELETE 没有应用侧重试,遇到首个 SQL 错误即终止 worker。本次诊断没有改动原始 500 并发的失败判定。

    若后续验证带重试的完整工作流,应作为明确标识的独立变体:仅对确认可安全重试的错误在新事务中有界退避重试,保留首次错误和重试次数,验证完整步骤及数据/元数据终态;不能把该变体冒充“原脚本无重试通过”。software_dev 完整 10,000 步、data_cleaning 及 mcts 的同版本收尾证据仍未补齐。

    测试证据

    测试结论

    本次确认了受测 DELETE 快速失败的回滚完整性与冲突消退后的新事务可重试性,没有证据将这些 20706 直接判为新的原子性 bug。但原始 500 并发流程尚未完成,当前不关闭 #29208、不发布整体通过结论。后续需明确高并发的应用重试合同并补足端到端完成证据。

  9. Ariznawlll commented on Oct 27, 2026

    @Ariznawlll
    Collaborator

    @gouhongshen 想请教一下 #29208 的验收预期和高并发冲突处理契约:

    在包含 #29798 的 main 533e95796177d9eacdc909059ccf72b7ddd3ba5f 上,原始 software_dev 场景以 500 workers × 20 steps、25 万行重跑时,500 个 worker 都在第 0 步的 DATA BRANCH DELETE TABLE 收到 20706: lock options conflict, wait policy is fast fail,最终完成 0/10,000 步。原脚本遇到首个 SQL 错误就停止 worker,没有应用侧重试。原始重跑 job

    后续在 main baa83f4b96e56ec214f92c68f7b56539b9e0fa45 做了 10 并发 DELETE 专项:113 次首次快速失败,在冲突消退后均能在新事务中首次重试成功;受测失败场景的数据和元数据检查一致。这个专项使用不同版本和 100 行 fixture,不能代表持续 500 并发的完整工作流。专项 job;完整测试记录。

    请确认:

    1. 独立分支表并发 DELETE 出现 20706 是否符合设计预期?调用方是否必须回滚整个事务,并在新事务中重试?
    2. 如果需要调用方重试,哪些错误可安全重试?对退避方式、重试上限和持续高并发下避免饥饿有什么建议或预期?
    3. [Bug]: 500 concurrent DATA BRANCH schema operations hit SNAPSHOT lock timeouts and lose connections #29208 是否以带明确重试的完整 500 并发工作流成功作为验收标准?此前也复现过的 data_cleaning 和 mcts 是否需要纳入?

    确认后会按约定补测,并分别记录原始无重试结果和明确标识的带重试结果,不将两者混为一谈。

  10. Ariznawlll commented on Dec 1, 2026

    @Ariznawlll
    Collaborator

    结论

    未完成验收。 在当前受测 main 上重新运行原始无重试 software_dev 工作流,500 workers ×20 steps、250,000 行:0/500 worker 完成,0/10,000 step 完成,500 个 worker 均报 20706。这一轮没有客户端 1205/2013,也没有 benchmark timeout,但不能因此说完整工作流已经正常。

    关键证据

    • MO 官方 main ec945a6323d4e505a8445bfd129f02a70073c301,启动后 git_version() 核对完整 SHA。修复 fix: avoid global lineage gate during ALTER COPY preparation #29798 已在受测 main 中。
    • 原始公开 harness 固定为 matrixorigin/mo-benchmark@e4a879b1e6a5cb41f650b37b7c2329bf3158f4de 的 git4data。没有修改 workload、删除失败判定、加入隐藏重试或用 DROP TABLE 替代 DATA BRANCH DELETE。
    • 128 上独立网络命名空间、独立数据目录及测试库;16 CPU quota / GOMAXPROCS=16、96 GiB cgroup memory、GOMEMLIMIT=64GiB。未使用 129。每个并发档位使用自己的新库与 250,000 行 fixture;这是同一独立 MO 进程依次执行三档,并非每档重新启动全新服务,也不做原机器资源完全一致的吞吐同比。
    • 每 worker 20 步,单 SQL timeout 120 秒,workload timeout 7,200 秒,seed=42。先跑 10、100 并发控制,再跑 500 并发。runner 自行创建初始数据,workload 结束后停止本轮自有 MO。
    并发 完成 worker 完成 step / 计划 step 失败 worker 错误 工作负载耗时(不含建表装载)
    10 1/10 20/200 9 9 个 20706 8.018 s
    100 0/100 0/2,000 100 100 个 20706 33.627 s
    500 0/500 0/10,000 500 500 个 20706 178.862 s

    三档 runner 均 exit 1;500 并发日志记录 500 次 agent_fork、500 次 step_failed、没有 step_completed。500 并发下 1,000 个 evaluation 查询/其他部分阶段成功不等于完整 step 成功;表中计数以原 harness 的完整步骤判定为准。

    500 并发实际首错一致:

    step 0: OperationalError:
    (20706, 'lock options conflict, wait policy is fast fail')
    

    原工作流每步依次执行 branch create、ALTER、UPDATE、evaluation、merge、delete;失败堆栈位于 session.delete_branch(child_branch, current_parent)。原 runner 在首次 SQL 错误后结束该 worker,因此本轮没有把重试后恢复计作原脚本成功。

    复现命令参数保持原始设置,连接环境指向本轮专属实例:

    python3 -m git4data.runner \
      --backend matrixone --workflow software_dev \
      --workers 500 --steps 20 --rows 250000 \
      --timeout-seconds 7200 --command-timeout-seconds 120 \
      --base-table g4d_base --output /path/to/owned-evidence/run-summary.json

    本次保存完整 run-summary.json、step-events.jsonl、版本检查、MO 日志和资源采样。无重试样本的结果如上;本轮没有重新执行以前的 113 组回滚/新事务重试专项,不把历史专项当成当前版本原子性证据。

    待解决点

    此前请求确认的重试契约 仍没有得到明确答复:独立分支 DELETE 的 20706 是否要求应用回滚并在新事务中重试,以及支持的重试边界、持续高并发下的完成标准。

    原 Issue 的期望允许“受控、可重试结果”,所以 20706 本身不能直接认定为新的产品缺陷;但它也不能作为原 500 并发流程验收成功。本次不新增主库 PR,不把失败场景改写成绿灯 MOTR,不关闭、不直接转交研发。

    最终结论:未完成验收。未完成项:当前 main 原始 500×20 无重试流程未完成,全部 worker 在首次 DELETE 阶段报 20706;持续高并发重试契约及完整工作流完成证据仍缺。原报告的 1205/2013 本轮未复现,这只是错误形态变化,不能等同整体修复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions