fanruan-tuco commented on code in PR #18522:
URL: https://github.com/apache/iceberg/pull/18522#discussion_r4399911212


##########
core/src/main/java/org/apache/iceberg/util/ParallelIterable.java:
##########
@@ -208,14 +227,18 @@ public synchronized boolean hasNext() {
 
       // this cannot conclude that there are no more records until tasks have 
finished. while some
       // are running, return true when there is at least one item to return.
-      while (checkTasks()) {
+      while (true) {
+        taskSignal.drainPermits();

Review Comment:
   Good catch. My tests missed two aspects of `drainPermits()`: 
    
     - It must run before `checkTasks()`. Your test covers this ordering, so 
I’ll add it along with a comment explaining why the order matters. 
     - It should actually be called. This is an optimization: without it, stale 
permits only cause extra loop iterations. Testing this deterministically 
without modifying `ParallelIterable` for test access is difficult, so I haven’t 
added a dedicated test for it.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to