Skip to content

[Bug]: Large-row merges panic when compression buffer growth exceeds mpool allocation limit #32051

Closed

Description

@aptend

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

IDC deployed build; the affected code is also present on main at d61a720.

Commit ID

7149815 (IDC deployed build).

Other Environment Information

IDC stability environment, DN merging objects with large TEXT values.

Actual Behavior

A merge produced a column of approximately 1.03 GiB. Its LZ4 compression scratch request was legal for one mpool allocation, but WriteArena.CompressBuf rounded the capacity up to 2 GiB. This exceeded mpool's single-allocation payload limit and triggered a panic reporting a requested allocation of 2147483648 bytes.

The DN process did not restart during the incident; I/O worker panics reduced the available workers.

Sorted merge checks output batch bytes only every 100 rows, allowing a skewed group of large rows to grow far beyond the soft block threshold before the next check. Reshape has no equivalent byte threshold and flushes only at the block row limit.

Expected Behavior

An otherwise legal compression buffer request should not fail solely because speculative capacity rounding crosses the allocator limit. Merge and reshape should flush oversized batches promptly while preserving row order and transfer mappings. Actual allocation failures should retain the existing panic behavior.

Steps to Reproduce

  1. Merge objects containing sufficiently large or skewed variable-length values, so a column grows beyond 1 GiB before the next 100-row size check (or before reshape reaches its block row limit).
  2. Persist the output block through the object writer's LZ4 compression path.
  3. Observe that a scratch request above 1 GiB rounds to 2147483648 bytes and mpool rejects it.

The capacity boundary can also be demonstrated without a GiB-sized allocation: arenaNextPow2((1 << 30) + 1) is 1 << 31, which exceeds mpool.MaxAllocationSize().

Additional information

Proposed fix:

  • Use the exact requested compression buffer size when the request is legal but power-of-two rounding would exceed mpool.MaxAllocationSize().
  • Check batch size after each appended row in sorted merge and reshape. Reuse the existing flush path when the batch exceeds 1.5 times the target object size (192 MiB for a 128 MiB target).
  • Preserve the schema row cap, source transfer stride and existing panic on allocation failure. The byte threshold remains soft because one indivisible row can exceed it.

Activity

  1. added
    kind/bug
    on Nov 3, 2026
  2. self-assigned this
    on Nov 3, 2026
  3. added a commit that references this issue on Nov 3, 2026
    88e5fb5
  4. added a commit that references this issue on Nov 3, 2026
    d2451d5
  5. XuPeng-SH commented on Nov 3, 2026

    @XuPeng-SH
    Contributor

    QA 交接(不是验收通过)

    修复 PR #32052 已合入 main,merge SHA:d2451d5c2e32c8c0bbab606a48f1f9c12de023ca。已核对本 issue 正文及完整评论、PR 修复范围与讨论,目前未见适用于新修复的已验证反例或未完成的开发 follow-up,交由 @Ariznawlll 回归。

    修复范围:合法的 LZ4 scratch 请求在向上取整会超过 mpool 单次分配上限时改用精确大小;sorted merge 与 reshape 每追加一行检查软字节阈值并复用 flush 路径,保留行数上限、顺序和 transfer 映射。单个不可拆分的大行仍可超过软阈值,真实分配失败仍按原逻辑 panic。

    验证证据(作者/远端报告,不是本轮本地实测):PR 作者报告 rebase 后 objectio、mergesort 两个完整包测试、静态检查及 license 检查通过;先前独立评审报告 owning-package 测试通过、基线控制能触发回归失败。最新合并队列记录显示 CI Required 成功并于 17:27 UTC 合入。历史失败/分支更新错误不代表当前修复仍未完成。

    未测范围及建议:本轮没有运行测试;已有容量边界测试未实际分配 GiB 级缓冲区。请在资源允许的 IDC 类环境回归约 1.03 GiB 列的 LZ4 写入、1 GiB/最大合法分配边界与非法请求;覆盖 sorted merge/reshape 的偏斜大行、删除行、持久化值和顺序、transfer 目标及 I/O worker 存活。确认真实 OOM 行为、单行超过软阈值、宽表与生产并发负载。作者旧基准显示部分小行/宽表有开销、偏斜场景累计 Go 分配可能增加,不应推断所有负载的内存或吞吐均改善。

  6. Ariznawlll commented on Nov 4, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。超过 1 GiB 的合法压缩缓冲区请求不再仅因向上取整失败;真实大行合并在软字节阈值处分块,结果及删除行正确。回归已提交 MOTR PR。

    关键证据

    • 2026-11-04 官方 main@0f6c07639604c40d7ca880cb63d1d282239def08,macOS arm64;独立 1 Log / 1 TN / 1 CN、本地 MinIO,MO git_version() 为 0f6c076396。
    • 在真实内存中对 1,107,296,256 字节(约 1.031 GiB)输入执行 LZ4 压缩和解压:WriteArena.CompressBuf 实际申请 1,111,638,610 字节,长度、容量及解压后的首/中/末标记一致,3/3;超过 allocator 上限的非法请求仍触发 panic,之后 arena 可重新使用、Reset 保留缓冲,3/3。该测试直接调用生产 arena 与 LZ4,并不声称是一次完整的 1.03 GiB 线上对象写入。
    • 定向 Go 集成测试使用 52 行 × 4 MiB,其中 1 行删除,在真实 128 MiB target / 192 MiB 软阈值下分别执行 sorted merge 和 reshape;输出 51 行、2 个块,完整逐行内容、顺序、删除标志和 transfer 映射正确,各 3/3;mpool 清理至零。修复前 8aa69be1cfffcb1374d8e0d40277dce9396db15c 的同一阈值断言在两个路径均失败(只有 1 块)。pkg/objectio 与 pkg/vm/engine/tae/mergesort 全包用例均成功。
    • 真实 SQL/MinIO 路径在 3 个独立表上写入 52 × 4 MiB、删除 1 行并触发 TN 合并;日志每次显示输出 192 MiB / 48 行与 12 MiB / 3 行。新增 MOTR 大数据回归实际检查合并元数据、51 个 id、每行长度及 CRC32,3/3;PR #305 的 CI 四项离线检查通过。该大数据用例需显式设置 MOTR_BIG_DATA_TESTS=1,在线测试由本地执行,非离线 CI 覆盖。
    • 同机对上述 208 MiB 定向 Go 场景交替执行修复前/后各 5 次:sorted 路径总耗时中位数 513/538 ms,reshape 为 585/558 ms;计时含构造、合并和读回,样本波动较大,只代表这一可压缩数据场景,不构成通用性能或生产吞吐结论。

    待解决点

    • 本轮未在 IDC 环境复现单个约 1.03 GiB 列经完整对象 writer 持久化,也未测多 worker 生产并发、真实 OOM 和小行/宽表性能分布;完整 MOTR issue-regression suite 未运行。线上资源与性能仍需结合实际负载观察。
  7. Ariznawlll commented on Nov 4, 2026

    @Ariznawlll
    Collaborator

    按新的验收要求重新打开本 Issue:此前“测试通过”的评论仅覆盖当时已执行的本地测试和 MOTR 专项用例,并不代表独立 big-data 流水线已经验收。

    独立 big-data 用例已提交至 PR #1903。每轮使用 286 行、每行 4 MiB,合计约 1.117 GiB 逻辑输入,验证真实合并的输出块上限、删除行、顺序与 CRC;最新 main 本地 3 轮通过。TKE 专项 run 41787647919 已触发,正在等待镜像构建和集群执行,尚无 big-data 流水线通过结论。该用例验证总输入超过 1 GiB 后的输出拆分,不声称产生了单列大于 1 GiB 的持久化块。

  8. Ariznawlll commented on Nov 4, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。独立 big-data TKE 专项已实际执行,超过 1 GiB 的逻辑输入经过大行合并后,输出块限制和完整结果校验均连续 3 次通过;专项回归已提交 PR。

    关键证据

    • Big Data TKE run 41787647919 成功;执行产品源码为 main@b27f3869e6f2552311fbbdda2f62b0ca31ec3a67,测试 workflow commit 为 fdcf33ab509c53208507fd5aa13d4d468f96552f。构建镜像、部署环境、专项执行及环境清理均成功;本次是 issue_32051 专项,不是整套 1Y/10Y 测试。
    • 每轮写入 286 行 × 4 MiB,合计 1,199,570,944 字节(约 1.117 GiB)逻辑数据;分 11 批 flush、删除一行并触发 L0 merge,验证物理输出块最多 48 行(192 MiB payload)、输出块数少于来源 flush 次数,且 285 行的 ID、顺序、长度及 CRC 正确。3 轮分别耗时 34.890、36.030、38.262 秒;物理块行数分别为 [21,25,48,48,48,48,48]、[25,33,36,48,48,48,48]、[46,48,48,48,48,48]。物理计数可包含被墓碑删除的行,逻辑查询已验证该行不存在。
    • 同一驱动在本地 main@b27f3869e6f2552311fbbdda2f62b0ca31ec3a67 连续 3 轮通过。此前直接调用生产 WriteArena.CompressBuf 和 LZ4,对约 1.031 GiB 输入完成压缩/解压 3/3;非法超上限请求的 panic/恢复及 sorted merge、reshape 路径分别验证通过,详见本 Issue 的上一条完整测试评论。
    • big-data 回归 PR #1903 已提交,包含独立专项调度、驱动及 pod 指标采样;PR 当前未合并,已运行的常规检查均通过。采样记录中单 Pod 最高值约 CN 2,574 MiB、TN 1,745 MiB,属于间隔采样,不代表精确峰值或全局内存上限。

    待解决点

    • 测试验证总逻辑输入大于 1 GiB 时的实际输出拆分;修复会主动分块,因此不声称在 TKE 对单个大于 1 GiB 的列块完成了对象持久化。未覆盖 IDC 原现场、多 worker 生产并发和完整 nightly 性能套件。
    • 回归 PR 等待评审与合入;按当前已提交回归、专项实跑通过的验收约定处理。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions