Skip to content

[Bug]: DROP TABLE after HNSW can fail during ISCP cleanup with transfer rowids length mismatch #28675

Closed

Description

@Ariznawlll

Description

在 main TKE nightly 的 HNSW + IVF benchmark 中,HNSW SIFT128 测试本身成功完成;紧接着 IVF SIFT128 初始化复用同一张表并执行 DROP TABLE IF EXISTS ann.items_sift 时,MatrixOne 在注销 HNSW ISCP 任务、更新 mo_catalog.mo_iscp_log 的过程中返回内部错误:

internal error: transfer rowids failed, length mismatch, expect 2, got 1

该错误具有时序性,发生在 HNSW 后台 ISCP 生命周期清理与前台 DROP TABLE 重叠的路径中。

Environment

  • Branch: main
  • Commit: 9a5dd0c6e32a62e4393c2e7fbcab57b53f0c58c0
  • Deployment: TKE distributed cluster
  • Namespace: mo-main-commit-9a5dd0c6e3-20260910
  • CN pod: nightly-regression-dis-tp-cn-bcn4v
  • Test date: 2026-09-11

Steps to reproduce

  1. 在分布式 TKE 集群中导入 SIFT128 1M 数据集到 ann.items_sift。

  2. 创建并执行 HNSW L2 benchmark,使 HNSW/ISCP 后台维护任务 index_hnsw_sift 处于已注册并工作过的状态。

  3. HNSW benchmark 结束后,不增加固定 sleep,立即启动复用同名表的 IVF SIFT128 case。

  4. IVF 初始化执行:

    DROP TABLE IF EXISTS ann.items_sift;
  5. 观察 DROP TABLE 返回内部 RowID transfer 错误。

完整复现入口:

https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34493586679/job/103126876200

Actual behavior

HNSW benchmark 已成功:

  • HNSW index create cost: 68,451.39 ms
  • QPS/TPS: 16,943
  • Recall: 92.50%
  • Successful queries: 4,870,962
  • Query errors: 0

随后 DROP TABLE 触发以下服务端错误链:

2026-09-11T02:47:15.782708Z
UPDATE mo_catalog.mo_iscp_log
SET drop_at = now()
WHERE account_id = 0
  AND table_id = 273139
  AND job_name = 'index_hnsw_sift'
  AND job_id = 1
error: txn need retry in rc mode

2026-09-11T02:47:16.792108Z
iscp get task runner timeout

2026-09-11T02:47:18.339537Z
transfer rowids failed, length mismatch, expect 2, got 1

对应 TRANSFER-ROWIDS-ERROR-LEN-MISMATCH 记录:

table-name: mo_iscp_log
table-id: 272467
intents: 2
actual: 1

前台语句最终失败:

DROP TABLE IF EXISTS ann.items_sift
internal error: transfer rowids failed, length mismatch, expect 2, got 1

Expected behavior

DROP TABLE IF EXISTS 应与 HNSW/ISCP 后台任务的注销和 drain 正确协调:

  • DROP TABLE 成功完成;或
  • 对内部可重试事务冲突进行透明、有限的重试。

不应将 mo_iscp_log 的 tombstone/RowID 转移内部错误返回给客户端,也不应依赖测试侧固定 sleep 才能正确删除表。

Stability and controls

Evidence

Code analysis

服务端日志显示,DROP TABLE 正在注销 index_hnsw_sift:

  1. iscp/watermark_updater.go 使用外层 DDL transaction 更新 mo_catalog.mo_iscp_log.drop_at,首先遇到 txn need retry in rc mode。
  2. ISCP task runner 查询和 rollback fence cleanup 随后超时。
  3. transaction unwind 期间,disttae/transfer.go 对 mo_iscp_log 进行 tombstone transfer,两个 transfer intents 只得到一个 target RowID,触发 length mismatch。

因此目前的根因方向是:DROP TABLE 与 HNSW ISCP unregister/drain 的异常回滚路径没有正确协调,导致系统表 tombstone transfer 的 RowID 基数不一致。具体是 retry 处理、drain 顺序还是 rollback cleanup 丢失 RowID,需要在修复时进一步确认。

Regression coverage

修复后建议加入无需固定 sleep 的重复回归:创建 HNSW 索引、产生 ISCP 更新,然后立即 DROP TABLE;连续执行并验证:

  • DROP TABLE 不返回内部错误;
  • 同名表可重新创建;
  • mo_iscp_log 不残留活动任务;
  • 无死锁、hang、panic 或 RowID transfer mismatch。

适合放在多客户端/后台任务时序覆盖的 MOTR 场景中,并为 ISCP rollback/unregister 增加定向 UT。

Related

Activity

  1. added this to the MO-202609 milestone on Sep 11, 2026
  2. added
    kind/bug
    on Sep 11, 2026
  3. added theissue type on Sep 11, 2026
  4. self-assigned this
    on Sep 11, 2026
  5. aptend commented on Sep 11, 2026

    @aptend
    Contributor

    Root-cause investigation is complete. The failure is caused by retry ownership in ISCP metadata helpers, not by RowID transfer itself.

    Evidence from the failing run

    Failing run: mo-nightly-regression 34493586679 / job 103126876200, MatrixOne commit 9a5dd0c6e32a62e4393c2e7fbcab57b53f0c58c0, namespace mo-main-commit-9a5dd0c6e3-20260910.

    Relevant UTC timeline:

    1. 02:47:15.239: the DROP transaction starts.
    2. 02:47:15.354: another CN commits the ISCP watermark update from LSN 31 to 32; AffectedRows=1.
    3. 02:47:15.777: the DROP transaction reads one matching mo_iscp_log row.
    4. 02:47:15.782: its first UPDATE mo_catalog.mo_iscp_log SET drop_at=now() returns txn need retry in rc mode.
    5. 02:47:16.788: UnregisterJob retries only its internal operation in the same caller transaction/workspace. The retry succeeds with AffectedRows=2, which is impossible in committed state because the predicate identifies the full (account_id, table_id, job_name, job_id) primary key.
    6. 02:47:17.637–02:47:17.827: TN flushes mo_iscp_log; the source object has 6 rows and 5 deletes, leaving one target row.
    7. 02:47:18.339: commit-time RowID transfer sees two source intents but only one target row and correctly reports transfer rowids length not match, expect 2, got 1.

    A successful control run, 34368139564 / job 102728417241, completed its watermark update before DROP. Its drop_at UPDATE affected one row, performed no local retry, and had no transfer mismatch.

    Root cause

    ExecWithResult executes ISCP sub-SQL with WithDisableIncrStatement().WithTxn(txn). These operations are part of the caller-owned SQL statement: they do not open an independent statement boundary, internal compile retry is disabled, and the internal executor does not roll back an existing caller transaction.

    However, RegisterJob, UnregisterJobsByDBName, UnregisterJob, RenameSrcTable, and UpdateJobSpec wrapped their work in the generic ISCP retry helper. When a mutating sub-SQL returned ErrTxnNeedRetry, the failed attempt remained in the caller workspace. Retrying only the helper reused that dirty workspace and added a second intent for the same logical primary-key row. The later strict transfer cardinality check exposed the duplicate intent.

    The correct retry unit is the outer caller-owned SQL statement. A retryable child error must escape immediately so Compile.Run can execute RollbackLastStatement, advance the statement generation, and replay the complete DDL.

    The messages containing iscp get task runner timeout and rollback fence cleanup timeout are not actual elapsed timeouts in this trace. They are timeout causes constructed when the contexts are created; subsequent operations completed successfully.

    HNSW is an exposure path rather than the correctness root cause. Frequent ISCP watermark updates make this RC conflict easier to hit. Relaxing or deduplicating the RowID transfer check would hide corrupted transaction state and is not the right fix.

    Fix

    PR #28693 removes local retry from the five caller-transaction ISCP metadata entry points while preserving the generic retry mechanism for self-owned background operations. A focused deterministic regression verifies that UnregisterJob returns the first retryable UPDATE error without issuing a fourth SQL execution; the existing register/unregister engine integration test also passes.

  6. assigned and unassigned on Sep 14, 2026
  7. Ariznawlll commented on Sep 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • 修复 PR: #28693 ,merge commit 7eb9e0a4cbf20ed9a8e696fc0c0fa2f2795c73d9。
    • 原始生命周期场景验证的 MatrixOne commit:a68a200c0bfb0c18f1b7f49d26b20b8d0d9b017f。
    • 当前 official main:07fdd4ae0f80f287b93fc4b525fd296d5617abc7,包含 fix(iscp): delegate caller transaction retries #28693。
    • 环境:TKE distributed;SIFT128 100 万向量;HNSW 查询结束后立即复用 ann.items_sift 执行 IVF L2、cosine、normalize 初始化。

    原问题验证

    故障版本 9a5dd0c6e32a62e4393c2e7fbcab57b53f0c58c0 中,DROP TABLE 与 HNSW ISCP unregister/watermark 更新发生 RC retry 冲突时,ISCP metadata helper 在 caller-owned DDL transaction 内局部重试。第一次失败的写入仍留在 caller workspace,第二次写入又为同一逻辑主键增加 transfer intent;最终 commit 的 RowID transfer 严格校验发现 expect 2, got 1,并将内部错误返回给 DROP TABLE。

    原始失败证据:run 34493586679 / job 103126876200。

    修复说明

    #28693 移除了 RegisterJob、UnregisterJobsByDBName、UnregisterJob、RenameSrcTable、UpdateJobSpec 等 caller-transaction ISCP metadata 入口的局部 retry。可重试子错误现在直接交给外层 SQL compiler,由外层执行 statement rollback 和完整 replay;自拥有 transaction 的后台任务仍保留原有 retry 机制。

    该修复避免在同一 caller workspace 内留下重复的 mo_iscp_log transfer intent,而没有放宽 RowID transfer 的基数校验。

    修复后验证

    修复后的原始 HNSW→IVF 连续生命周期路径已在 TKE main nightly 执行:

    • 验证 Job:run 34764591964 / HNSW AND IVF VECTOR INDEX Benchmark Test,状态为 success。
    • HNSW SIFT128 5 分钟查询完成:4,987,236 successful queries、0 query errors、QPS 16,786、Recall 92.23%。
    • HNSW 结束后立即进入 IVF SIFT 初始化;DROP TABLE IF EXISTS ann.items_sift 成功执行。
    • 随后 IVF cosine 和 IVF normalize 初始化再次复用同名表,两次 DROP TABLE IF EXISTS ann.items_sift 也均成功。
    • 整个 Job 共记录 4 次 DROP TABLE IF EXISTS ann.items_sift,均未返回异常;IVF L2、cosine、normalize 的索引创建均成功。
    • Job 完整日志中 transfer rowids failed、length mismatch、txn need retry in rc mode、iscp get task runner timeout 均为 0 次。

    回归测试

    #28693 增加 TestUnregisterJobPropagatesRetryableErrorWithoutLocalRetry,验证 UnregisterJob 遇到 retryable UPDATE 错误后只执行第一次尝试并向外层传播;既有 TestISCPRegisterUnregisterIdempotence 同时通过。PR 的 CI Required、TKE BVT、分布式 multi-CN BVT、UT、TPCH/SSB、Sysbench、TPCC 与覆盖率检查均通过。

    测试证据

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s-1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions