Offset overflow - JVM columnar shuffle cuts row-to-Arrow batches by row count only

未关闭
#7,497 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust, scala, spark

调研方向

Start with native/shuffle/src/spark_unsafe/row.rs, especially process_sorted_row_partition at lines 1579–1588 and its existing row size handling; compare it with process_sorted_partitions at line 1686. Add byte budget coverage alongside the row limit, then follow the issue’s test plan: use a small budget and verify several blocks are written and the same rows read back.

由索引模型根据 Issue 内容生成。

描述

area:shuffle bug priority:high

Part of #7267.

Problem

The JVM columnar shuffle hands sorted UnsafeRows to native code, which converts them to Arrow in batches of spark.comet.shuffle.jvm.batchSize rows, capped by spark.comet.batchSize. Both entry points cut batches by row count only: process_sorted_partitions splits each partition's rows with run.chunks(batch_size) (native/shuffle/src/spark_unsafe/row.rs:1686), and process_sorted_row_partition does the same at :1579-1588. Strings and binaries are appended with arrow's append_value (:1173-1203), which panics with byte array offset overflow once a column passes 2 GiB. Strings inside arrays, maps and structs go through the same builders.

So a batch fails when one string or binary column holds more than 2 GiB, which is more than about 256 KiB per value at 8192 rows. When the column is dictionary-encoded, the writer succeeds and the reader fails instead (#7496). When the dictionary doesn't pay off, the cast back to plain values returns OffsetOverflowError (row.rs:1777). Spark shuffles rows and has no batch to overflow.

#7269 covers the native shuffle writer, which is separate code.

Line references are for main at 4e6b12290f.

Workaround

Lower spark.comet.shuffle.jvm.batchSize.

Proposed fix

Cut batches by bytes as well as rows. The row sizes are known before conversion (row_sizes), and a row's size bounds the bytes it adds to any column, so ending a batch before the sum of its row sizes passes i32::MAX keeps every column valid without looking at the values.

Tests

Inject a small byte budget and check that process_sorted_row_partition writes several blocks for rows that would otherwise share one, with the same rows read back.

主要语言
Scala
星标
1.3k
派生
414
平均合并
3 天 4 小时
30 天内合并 PR
202

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion-comet 的其他 Issue

查看 apache/datafusion-comet 的全部 Issue

相似的 Issue

更多 Scala Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。