Ruifeng Zheng created SPARK-62416:
-------------------------------------

             Summary: Defer grouped Python Arrow cleanup during active writes
                 Key: SPARK-62416
                 URL: https://issues.apache.org/jira/browse/SPARK-62416
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 5.0.0
            Reporter: Ruifeng Zheng


GroupedPythonArrowInput and CoGroupedArrowPythonRunner use ArrowWriterWrapper 
to write a separate Arrow stream for each group. Its task completion listener 
currently closes the vectors and allocator unconditionally. If a caller 
consumes the upstream Python iterator on a helper thread (for example, JVM 
Dataset.rdd.pipe), task completion can overlap an input write or stream 
initialization. This can release Arrow buffers while they are still being used.

This is a pre-existing issue in the grouped/cogrouped writers. SPARK-62406 and 
https://github.com/apache/spark/pull/60843 cover PythonArrowInput's shared 
writer, which these writers bypass. This ticket tracks their lifecycle fix 
separately.

Coordinate group writer initialization, active writes, and task completion. 
Task completion must return without waiting for upstream I/O, with cleanup 
deferred until an active write exits. Reject further writes after completion 
before consuming input or writing group markers. Preserve startup-failure 
cleanup, normal group EOF markers, and idempotent resource release without 
emitting an Arrow footer from task-completion cleanup.

Add deterministic lifecycle regressions for grouped and both cogrouped sides, 
including successful and failed active writes, completion before the first 
write and between batches, initialization failure, empty cogroups, group 
boundaries, normal EOF, and idle completion. Keep Arrow output-reader cleanup 
outside this change.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to