[SQL] State-store instance metrics are shipped in every task result
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- data-engineering, distributed-systems
Hướng nghiên cứu
Bắt đầu với StateStoreWriter.stateStoreInstanceMetricsWithIds và setStoreInstanceMetrics, sau đó lần theo cách xử lý accumulator qua AccumulatorV2.readObject, Task.collectAccumulatorUpdates, Executor và TaskSetManager.canFetchMoreResults. Tái hiện workload ResultStage có số lượng partition cao được mô tả và kiểm tra kích thước kết quả của task. Phần hoàn tất cần ngăn các metric instance của state store không liên quan làm phình to kết quả task đầu cuối, đồng thời vẫn giữ lại các metric tiến độ bắt buộc của state operator.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Stateful operators currently create one state-store instance metric accumulator for every combination of:
state partition
x supported provider metric
x state-store name
Every task then receives and registers all of those accumulators, even though it processes only one state partition. On task completion, all external accumulators are included in the task result.
For a job with 20,000 shuffle partitions, RocksDB state, and one default store, this can result in approximately 20,000 state-instance metric updates per task.
Reproduction
A representative workload is:
spark.sql.shuffle.partitions = 20000
stateful operator using RocksDB state
checkpoint or write the stateful result
Observed behavior:
per-task result size: approximately 3 MiB
number of tasks: approximately 20,000
terminal stage: ResultStage
The cumulative task-result data can therefore be approximately 60 GiB. The job may fail with spark.driver.maxResultSize even though the actual rows are written or checkpointed by executors.
The same issue can occur with direct file writes because the final write stage is submitted through SparkContext.runJob and uses ResultTasks. Each task returns a commit result plus accumulator updates.
Root cause
Relevant code paths on master include:
StateStoreWriter.stateStoreInstanceMetricsWithIdscreates metrics for all state partitions, supported metrics, and store names.StateStoreWriter.setStoreInstanceMetricsupdates the corresponding per-instanceSQLMetric.AccumulatorV2.readObjectregisters all deserialized accumulators with the task.Task.collectAccumulatorUpdatessends all external accumulators on successful task completion.Executorserializes those accumulator updates intoDirectTaskResult.TaskSetManager.canFetchMoreResultsappliesspark.driver.maxResultSizetoResultStages.
ignoreIfUnchanged and numStateStoreInstanceMetricsToReport are applied while generating state-operator progress after the driver has received and merged the updates. They do not reduce the task-result payload.
Why checkpointing and direct writes are affected
RDD checkpoint materialization calls SparkContext.runJob, making the checkpointing stage a ResultStage.
Direct file writes also use runJob and return per-task write results or commit messages to the driver. Those task results contain the write result plus accumulator updates, so state-store metrics can contribute to the cumulative result size.
The spark.driver.maxResultSize check is not enforced for upstream ShuffleMapStages, but it is enforced for these terminal ResultStages.
Impact
This behavior causes:
- inflated task-result serialization and network traffic;
- increased executor and driver deserialization work;
- large
CompletionEventpayloads on the driver; - driver heap pressure if result processing falls behind task completion;
- possible
spark.driver.maxResultSizefailures; - increased per-task metric metadata retained by scheduler or UI structures.
Scope
This is not specific to TransformWithState. It can affect any stateful operator using StateStoreWriter and a provider that exposes state-store instance metrics.
Multiple state stores, such as those used by streaming joins, multiply the number of metrics included in each task result.
- Ngôn ngữ chính
- Scala
- Star
- 44.2k
- Fork
- 29.5k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/spark
-
[BUILD] Bump Ivy up to 2.6.0Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[SQL][CONNECT] SparkConnectClient may drop metadata (auth headers) on retried/reattached RPCs if metadata is a non-list iterableCó thể đã có người làm @zainmirzaaa đã nhận 62 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[CORE] bug report: collision of resource profile idCó thể đã có người làm @ybapat đã nhận 88 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
apache/spark#57498 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUILD] Drop oro dependencyĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
apache/spark#57209 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Merge spark PR script hard blocks on JIRACó thể đã có người làm @holdenk đã nhận 1 ngày trước. Đang mở
apache/spark#59693 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
enhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
spotify/scio#6018 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
scylladb/scylla-migrator#417 ·
-
[Docs] Document `spark.databricks.delta.optimize.maxThreads` in Compaction (bin-packing) sectionCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdelta-docs delta-table-maintenance documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
software-mansion/starknet-jvm#641 ·