fix: fail the task when Spark throws during a native memory request #7607
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 334 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.348
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7607"
general
weight: 0.35
JonSnow1807
Which issue does this PR close?
Part of #7244.
Rationale for this change
Two native memory paths treat an exception from Spark during a memory request as a refusal:
try_growerror, so an exception (for example a failed spill of another consumer, or a killed task) makes it spill and carry on.growon the Spark-backed pools logs the failed call and books the size as overcommit, so the exception only reaches the log.What changes are included in this PR?
multi_partition.rs: spill only when the error is a refusal (ResourcesExhausted, found withfind_root, the sameis_refusalas the Iceberg writer, now indatafusion-comet-common). Any other error fails the shuffle.SparkMemorykeeps the first request to Spark that fails, ingrowortry_grow, and every latertry_growof the task then fails without asking Spark. Each of them fails with the exception Spark threw, so the task fails with it when the operator passes the error on unchanged.growbooks its whole size as overcommit without asking Spark.growstays infallible.delta_dv.rs: only a refusal gets the size message. An exception from Spark keeps its class.memory_management.mdandnative_shuffle.md.The failure is kept rather than handed out once because DataFusion’s sort and multi-level merge take any
try_growerror as a refusal and ask again, which would drop a one-time error.One gap is left: a failed
growwith no latertry_growin the task is still only logged. Closing it would mean checking for the failure when a plan’s stream ends injni_api.rs, which changes the JNI plan lifecycle, so I left it out. I’ll do that in a follow-up. DataFusion’s sort-merge join also treats anytry_growerror as a refusal, so it is covered by #7615.How are these changes tested?
New unit tests, each failing on main and passing with this change:
pool_errors_other_than_refusal_fail_the_shufflea_failed_acquire_fails_every_later_try_acquirea_failed_try_acquire_fails_every_later_onea_failed_grow_fails_every_later_try_grow_of_the_task(greedy and fair unified pools)attach_access_plans_fails_with_the_exception_spark_threwa_refused_reservation_spillschecks that a refusal, also when wrapped inContextorShared, still spills.cargo test -p datafusion-comet-shuffleandcargo test -p datafusion-comet --libpass, and clippy is clean.