You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "QuakeWang (via GitHub)" <gi...@apache.org> on 2026/07/27 03:09:46 UTC

[PR] [common] Ensure ParallelExecution waits for reader cleanup [paimon]

QuakeWang opened a new pull request, #8855:
URL: https://github.com/apache/paimon/pull/8855

   ### Purpose
   
   `ParallelExecution` marks tasks complete before closing the underlying readers, while `close()` previously only interrupted the executor. As a result, `close()` could return while reader cleanup was still running, leaving input streams temporarily
     open.
   
   Wait for executor termination in `close()` so reader resources are released before it returns. Add deterministic coverage for the race and remove the sleep workaround from `IndexBootstrapTest`.
   
   ### Tests
   
     - `mvn -pl paimon-core -am -DfailIfNoTests=false -DwildcardSuites=none -Dtest=ParallelExecutionTest,IndexBootstrapTest test`
     - Ran `testBootstrapIgnoresQueryAuth` 1,000 times concurrently on JDK 11


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [common] Ensure ParallelExecution waits for reader cleanup [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #8855:
URL: https://github.com/apache/paimon/pull/8855#issuecomment-5125707314

   +1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [common] Ensure ParallelExecution waits for reader cleanup [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #8855:
URL: https://github.com/apache/paimon/pull/8855#issuecomment-5088794924

   Could we avoid interrupting workers that have already finished reading and are only closing their readers?
   
   `latch.countDown()` happens before the try-with-resources closes the iterator. Therefore, after `take()` observes completion, the worker may still be inside `RecordReader.close()`. Calling `shutdownNow()` here interrupts that cleanup. `awaitTermination()` then only guarantees that the worker exited; it does not guarantee that cleanup completed successfully.
   
   I reproduced this with a reader whose `close()` waits on an interruptible semaphore. `ParallelExecution.close()` interrupted the cleanup and returned before the semaphore was released, with the cleanup operation never completed. The new test uses `acquireUninterruptibly()`, so it cannot expose this race.
   
   For the normal completed-read path, could we use `executorService.shutdown()` when `latch.getCount() == 0`, and reserve `shutdownNow()` for early cancellation? Alternatively, moving the countdown after resource cleanup would also avoid this race.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [common] Ensure ParallelExecution waits for reader cleanup [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #8855:
URL: https://github.com/apache/paimon/pull/8855


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [common] Ensure ParallelExecution waits for reader cleanup [paimon]

Posted by "QuakeWang (via GitHub)" <gi...@apache.org>.
QuakeWang commented on PR #8855:
URL: https://github.com/apache/paimon/pull/8855#issuecomment-5111703894

   Thanks @JingsongLi for catching this. You are right that `shutdownNow()` could interrupt reader cleanup after `take()` had already observed completion.
   
   Fixed in `d16774b2b`. `ParallelExecution.close()` now uses `shutdown()` when all readers have finished reading, while retaining `shutdownNow()` for early cancellation. I chose this approach to preserve the existing behavior where `take()` does not wait for reader cleanup.
   
   I also changed the test to use interruptible semaphore acquisition and propagate interruption as an `IOException`, so it now exposes this race. Both `ParallelExecutionTest` and `IndexBootstrapTest` pass.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org