Skip to content

[Bug]: 10M IVFFLAT CREATE INDEX stalls in mapping with repeated ISCP transaction finish timeouts #29183

Closed

Description

@Ariznawlll

Existing issue check

Branch and commit

  • Branch: main
  • MatrixOne commit: bc523def3b55de2b305c14ee9fafb61dfec24126
  • Regression workflow revision: e6b23fca19cd1802979131467bd54ca14015d898

Environment

Actual behavior

CREATE INDEX does not finish after the data load has completed. The KMeans phase completes, but the following mapping/entries-write phase does not reach completion and emits iscp transaction finish timeout repeatedly for more than two hours. The test wrapper later cancels the still-running SQL at its three-hour deadline.

Observed sequence (UTC):

  1. 18:16:58: S3 load completes with affected_rows=10000000.
  2. 18:16:59: CREATE INDEX idx_l2 ... USING ivfflat starts.
  3. 18:17:08 to 18:31:00: KMeans runs and completes.
  4. 18:31:01: centroids are inserted and the index status reaches mapping_start.
  5. From 18:31:07 onward: TP CN logs internal error: iscp transaction finish timeout approximately every 10 seconds. There is no matching mapping_end event before cancellation.
  6. 20:41:44: the outer test command reaches its three-hour limit and exits with code 124.
  7. 20:41:48: the server records context canceled for the internal mapping INSERT ... SELECT. This cancellation is a consequence of the wrapper deadline, not the first failure.

No pod restart, panic, or OOM was observed in the incident window. TP-CN profiling continued to show CPU activity; Go heap was about 2.1 GiB and MO mpool about 18.2 GiB near the deadline. Therefore the available evidence is a stalled/failing ISCP completion path during IVF mapping, not an OOM termination or a test-result assertion failure.

Expected behavior

For the stated 10M dataset and IVF parameters, CREATE INDEX should finish successfully and emit the mapping-completion status. It must not remain in the mapping phase while repeatedly timing out ISCP transaction completion until an external test deadline cancels it.

Steps to reproduce

  1. Deploy the stated distributed topology on main.
  2. Load 10,000,000 Wiki VECF32(768) rows into a table.
  3. Execute:
CREATE INDEX idx_l2
USING ivfflat ON historical_file_blocks_wiki_ivfflat10m(embedding)
lists=3162 op_type 'vector_l2_ops' quantization 'float32'
kmeans_train_percent 2 kmeans_max_iteration 20;
  1. Observe index-build status and TP CN logs through completion or timeout.

Validation status and impact

Suggested diagnostics

  • Correlate the first ISCP finish timeout with the lifecycle and transaction state of the IVF mapping writer.
  • Preserve per-iteration change volume, transaction duration, retries, and mapping progress, so a blocked build can be distinguished from slow but progressing work.
  • After a product fix, rerun this exact 10M build and require successful mapping completion without any iscp transaction finish timeout.

Related

Activity

  1. added this to the MO-202609 milestone on Sep 21, 2026
  2. added
    kind/bug
    on Sep 21, 2026
  3. added theissue type on Sep 21, 2026
  4. LeftHandCold commented on Sep 21, 2026

    @LeftHandCold
    Collaborator

    补充同一现场的 CPU profile、前一轮对照和代码定位:本次已确认的主要瓶颈是 IVF mapping/质心分配的距离计算,证据高度指向 #29143 引入的普通 float32 建索引性能退化。不能仅凭重复的 iscp transaction finish timeout 就认定 ISCP completion 是根因。

    1. 同一问题,不是新增的 Wiki 校验失败

    • 失败准备 Job
    • MO:bc523def3b55de2b305c14ee9fafb61dfec24126
    • Runner:e6b23fca19cd1802979131467bd54ca14015d898
    • Namespace:mo-main-family-35518551829-1
    • TP pod:nightly-regression-dis-tp-cn-t2g8l
    • 1TP + 2AP;CN 55Gi / Cache 16Gi;TN 32Gi。

    1000 万行 LOAD DATA 已成功。CREATE INDEX 未完成后,外层 10800 秒准备预算终止客户端,返回 124;之后服务端的 context canceled 是取消结果。后续 IVF 查询 Job 因 prepare 失败被拦截,六模式实际是 not_run,不是查询正确性检查失败。

    近期 Runner 修改也不在这个失败路径:mo-nightly-regression#1710 的审计在查询后执行,#1714 的固定入口改动作用于 recall 而不是 prepare;新 #1718 尚未合并,未进入这轮运行。

    2. 前一轮相同准备任务正常,本轮慢在建索引,不是装载

    对照:前一轮成功的 prepare,MO be1591fb50dd653ce58560997e115e5050053980,Namespace mo-main-family-35450514491-2。

    两轮 vector_benchmark 均为 0bae04528673d7756c4ee2478ac8e4e41f54df1b;数据、CREATE INDEX SQL、workload=tp 和上述内存配置一致。

    阶段 前一轮 本轮
    S3 LOAD DATA 36分40秒 35分14秒
    CREATE INDEX 22分33秒完成 144分45秒仍未完成,随后被取消

    因此本轮建索引在取消前,耗时已超过前一轮的 6.4 倍。这是未完成耗时的下界,不是完整执行时间比值。

    本轮 KMeans 在 UTC 18:31:00 已完成,centroids 在 18:31:01 已写入;之后持续执行 entries 的 INSERT ... SELECT ... CENTROIDX JOIN,直到 UTC 20:41:48–49 被取消。

    3. 直接 CPU 证据:持续执行距离计算,不是空等

    Grafana 环境 tke,Pyroscope datasource pyroscope:

    selector = {service_name="mo-main-family-35518551829-1/main",pod="nightly-regression-dis-tp-cn-t2g8l"}
    profile type = process_cpu:cpu:nanoseconds:cpu:nanoseconds
    window = 2026-09-20 20:15:00–20:20:00 UTC
    sample total = 3912.12 CPU seconds / 300 wall seconds
    

    调用链:

    Productl2.Call -> probeRun
      -> GoBruteForceIndex.SearchFloat32
      -> StableL2DistanceSq
      -> stableDifferenceScale / math.IsInf / math.IsNaN
    

    关键占比:

    • StableL2DistanceSq:累计 96.60%,自身 51.62%。
    • stableDifferenceScale:累计 44.84%,自身 21.30%。
    • math.IsInf 自身 13.00%;math.IsNaN 自身 7.63%。
    • 累计占比存在嵌套,不能相加。

    AP SSB/TPCH 在 UTC 19:08:47 已结束。Prometheus 在 19:15–20:40 的 60 秒采样、2 分钟 CPU rate 显示:TP 平均 13.99 核,两个 AP 分别约 0.175 / 0.172 核,TN 约 0.98 核。此时 ANLI 和 TP 后续重负载尚未开始。因此不能把后半段持续变慢归因为 IVF/ANLI 并发。最终资源门禁也显示 9 个 Pod 均无重启、未报告 OOM。

    4. 与 #29143 的直接代码联系

    #29143 于 2026-09-20 12:56 UTC 合入,commit 39cc357e3895389915b98e45caeba40024c125f1,已包含在失败版本中:

    1. NewCpuBruteForceIndex 将 float32 数据的实例从 <float32,float32> 改成 <float32,float64>。
    2. ResolveDistanceFn 将这类宽结果 L2 分派到 StableL2DistanceSq[float32]。
    3. StableL2DistanceSq 每次距离计算先扫描 scale/NaN/Inf,再逐维执行 float64 缩放除法和累加;这与现场热点逐项吻合。镜像虽然使用 GOEXPERIMENT=simd 构建,该稳定算法仍绕过原有 typed L2 的 SIMD 选择路径。

    **归因边界:**当前是实际运行热点 + 精确代码变更 + 前轮对照,尚未做 #29143 父子 SHA 的同环境受控复跑;不能把整轮所有其他失败都归给这个 PR。

    5. 修正 ISCP 判断及建议

    在 UTC 18:16:07 等时间点,CREATE INDEX 开始前就已有 iscp transaction finish timeout。这些日志需要另行关联事务/任务身份,不能仅凭出现时间就视为本次 mapping 停滞的起因,也不宜把“环境里完全不再出现这条日志”当作本问题唯一验收条件。

    建议优先检查 #29143 普通有限 float32 输入的距离热路径,保留极端值正确性,同时恢复常见输入的高效实现;不要只提高 Runner 超时或直接撤销数值正确性修复。验收至少比较建索引完成耗时、距离计算 CPU 开销及极值正确性,并确认后续六模式能够实际执行。

    本次仅补充证据,没有修改 Runner、MO 内核或集群,也没有重新启动长任务。

  5. Lundomn commented on Sep 21, 2026

    @Lundomn
    Contributor

    Root cause confirmed: this is a post-merge performance regression from #29143, not a new ISCP correctness failure. The widened float32 result type preserved #29083's extreme-value correctness, but routing normal float32 L2 distances through StableL2DistanceSq added a per-call scale/NaN/Inf scan. The #29183 CPU profile shows that scan dominating IVFFLAT centroid assignment.

    A complete fix is submitted in #29194:
    #29194

    The PR keeps float64 accumulation and ordering, adds a single-pass finite float32 -> float64 L2 kernel, and falls back to the stable implementation for non-finite inputs. It includes range/precision/NaN/Inf tests plus real Search/SearchFloat32 consumer coverage. Local metric and brute-force suites, vet, and benchmarks pass; the target 10M-row TKE run remains part of CI/QA validation.

  6. Ariznawlll commented on Sep 26, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • 验证 MatrixOne commit:7ce783464806490263c184f22aaf5d307225adef
    • 修复提交:3b34a2ee533445fefe8e9b887c06bd6bd0260f33(#29100)
    • 验证时间:2026-09-25
    • 部署拓扑:TKE,1 TP CN + 2 AP CN;通过 TP CN 执行建索引

    验证 commit 已包含修复提交:相对 3b34a2ee533445fefe8e9b887c06bd6bd0260f33 为 ahead 32 / behind 0。当前 main 也已包含该修复。

    原问题验证

    使用与本 issue 一致的数据规模、向量维度和建索引参数复测:

    • 数据集:Wiki,共 10,000,000 行
    • 向量列:VECF32(768)
    • 索引:IVFFLAT / L2
    • 参数:lists=3162、quantization=float32、kmeans_train_percent=2、kmeans_max_iteration=20
    • LOAD DATA 成功,affected_rows=10000000
    • CREATE INDEX 成功,耗时 1260.86 s,约 21分01秒
    • 建索引过程未再次出现 mapping 长时间停滞,也未因外层 3 小时截止时间被取消
    • 本次 Job 日志中未出现原失败现场的 iscp transaction finish timeout

    功能验证

    • 10M/768 维完整数据成功装载,不是缩小数据量后的替代验证。
    • IVFFLAT 索引按照 issue 中相同的 L2、float32 quantization 和 KMeans 参数创建完成。
    • 索引创建后的路由证据检查为 PASS,准备阶段整体成功退出。

    异常与边界验证

    • 原失败版本在相同阶段运行超过 144分45秒 仍未完成,最终被外层截止时间取消;修复版本在 21分01秒 内完成。
    • 本次没有通过增加 Runner 超时掩盖问题,原来的 10M 建索引路径已在正常预算内完成。
    • 同一轮后续 recall Job 出现的查询阶段连接/质量回执问题属于独立问题,不是本 issue 的 CREATE INDEX mapping 卡死复现。

    白盒验证

    根因对应普通 float32 L2 距离计算被路由到高开销稳定实现,导致 IVFFLAT 质心分配阶段 CPU 热点和严重性能退化。合入的 #29100 已移除该高开销路径并恢复常规输入的快速距离计算;上述目标规模复测确认修复后的实际建索引路径能够完成。

    回归测试

    场景 MatrixOne 版本 结果 CREATE INDEX 耗时
    退化前基线 原正常版本 成功 22分33秒
    问题版本 bc523def3b55de2b305c14ee9fafb61dfec24126 失败,未完成后被取消 >144分45秒
    修复后验证 7ce783464806490263c184f22aaf5d307225adef 成功 21分01秒

    修复后耗时已恢复到退化前基线范围,原问题未复现。

    测试证据

    测试结论

    测试通过。

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