Spark: Async micro-batch preload does not stop when either limit is reached

オープン 初心者向け
#17,951 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #17950 @iamrajatrana による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
90/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, spark

調査の方向性

AsyncSparkMicroBatchPlanner.fillQueueInitialBuffer から始め、初期プリロード条件を同じクラスのバックグラウンド補充パスと比較します。両方の非対称な行数/ファイル数制限状態について、対象を絞った Spark 4.1 のリグレッションテストを実行または拡張し、その後、対応する修正を 3 つの Spark バージョンすべてに適用して、テストが成功することを確認します。

索引モデルが issue の本文から書いたものです。

説明

Spark: Async micro-batch preload does not stop when either limit is reached

Apache Iceberg version

main (0107f19a4a); present in Spark 3.5, 4.0, and 4.1.

Query engine

Spark Structured Streaming with async-micro-batch-planning-enabled=true.

Description

AsyncSparkMicroBatchPlanner.fillQueueInitialBuffer combines the initial row and file limits with
||:

while ((queuedRowCount.get() < targetRows || queuedFileCount.get() < targetFiles)
    && current.snapshotId() != preloadEndSnapshot.snapshotId()) {

This continues preloading until both limits are reached. It should stop when either limit is reached,
which requires && between the two below-limit checks.

This is also consistent with the background-refill path in the same class, which considers the
buffer full when either its row or file threshold is exceeded.

The default initial limits are 100 files and 100,000 rows. For example, if each pending snapshot adds
100 one-row files, the file limit is reached after the first snapshot, but current code can continue
through 1,000 snapshots and retain 100,000 file tasks before reaching the row limit. The inverse
happens when snapshots contain a small number of files with many rows.

This affects startup and catch-up with a snapshot backlog, such as after downtime, restart from an
old checkpoint, or AvailableNow processing. Extra preload causes unnecessary manifest planning,
driver allocations, startup latency, and possible memory pressure. It does not cause data loss.

Proposed fix

Use && in all three Spark versions:

while ((queuedRowCount.get() < targetRows && queuedFileCount.get() < targetFiles)
    && current.snapshotId() != preloadEndSnapshot.snapshotId()) {

Add regression coverage for both asymmetric states:

// File limit reached, row limit not reached
assertThat(shouldContinueInitialPreload(1L, 100L, 100_000L, 100L)).isFalse();

// Row limit reached, file limit not reached
assertThat(shouldContinueInitialPreload(100_000L, 1L, 100_000L, 100L)).isFalse();

A focused Spark 4.1 test failed with the current || condition and passed after changing it to
&&.

Snapshots are added atomically, so preload may still exceed a limit by one snapshot. Strict
within-snapshot enforcement is outside this fix.

Willingness to contribute
  • I can contribute a fix independently
  • I would be willing to contribute a fix with guidance
  • I cannot contribute a fix at this time
主要言語
Java
スター
9.4k
フォーク
3.7k
平均マージ
2日 16時間
マージ済み PR(30日)
160

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/iceberg のほかの issue

apache/iceberg の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。