dwsmith1983 commented on code in PR #5613:
URL: https://github.com/apache/datafusion-comet/pull/5613#discussion_r3930833884


##########
native/core/src/execution/memory_pools/fair_pool.rs:
##########
@@ -124,19 +162,25 @@ impl MemoryPool for CometFairMemoryPool {
 
     fn shrink(&self, _reservation: &MemoryReservation, subtractive: usize) {
         if subtractive > 0 {
-            let mut state = self.state.lock();
-            // We don't use reservation.size() here because DataFusion 53+ 
decrements
-            // the reservation's atomic size before calling pool.shrink(), so 
it would
-            // reflect the post-shrink value rather than the pre-shrink value.
-            if state.used < subtractive {
-                panic!(
-                    "Failed to release {subtractive} bytes where only {} bytes 
tracked by pool",
-                    state.used
-                )
+            {
+                let mut state = self.state.lock();
+                // We don't use reservation.size() here because DataFusion 53+ 
decrements
+                // the reservation's atomic size before calling pool.shrink(), 
so it would
+                // reflect the post-shrink value rather than the pre-shrink 
value.
+                if state.used < subtractive {
+                    panic!(
+                        "Failed to release {subtractive} bytes where only {} 
bytes tracked by pool",
+                        state.used
+                    )
+                }
+                state.used -= subtractive;
             }

Review Comment:
   One more window closed in 353541d59, found while probing the anchor 
bootstrap with a third task. Before the anchor lands, a short grant is handed 
back whole; if another task's entry disappears in that gap (raising this task's 
minimum share) and a sibling acquire of this task then parks, the rollback 
release zeroes the entry under it. A small bootstrap mutex now serializes 
anchor carriers from the bridge acquire through the rollback release. Releases 
never take it, so a parked carrier cannot starve anyone, and non-carriers only 
exist once the anchor is held. Pinned as 
`short_grant_rollback_cannot_land_under_a_sibling_parked_in_spark`, which 
failed with `key not found` before the change.



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