Yuchen Liu created SPARK-62369:
----------------------------------

             Summary: ChecksumCheckpointFileManager leaks a created stream when 
the other create fails or the wait is interrupted
                 Key: SPARK-62369
                 URL: https://issues.apache.org/jira/browse/SPARK-62369
             Project: Spark
          Issue Type: Bug
          Components: Structured Streaming
    Affects Versions: 4.1.0
            Reporter: Yuchen Liu


ChecksumCheckpointFileManager.createWithChecksum (used by createAtomic and 
createAtomicIfAbsent) creates the main file and its .crc file in two futures on 
its thread pool, then waits for both with awaitResult and builds the 
ChecksumCancellableFSDataOutputStream from the two results. If either wait 
throws, the caller gets no stream to cancel, and nothing cancels the stream 
whose create succeeded:
 * The .crc create fails: the main file's stream from the first future is never 
cancelled.
 * The main create fails: the .crc stream from the second future is never 
cancelled.
 * The calling thread is interrupted while waiting (for example a state store 
commit that is aborted by interrupting its thread): both creates finish on the 
pool, and neither stream is cancelled.

With a rename-based CheckpointFileManager this leaves the temp file 
(.<name>.<uuid>.tmp) in the checkpoint directory; with other file systems the 
open output stream is leaked. The same happens with numThreads = 0, where both 
creates run before the waits.

Proposed fix: when waiting for either create fails, cancel each stream once its 
create completes, and rethrow the original failure.



--
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