xanderbailey commented on code in PR #20672:
URL: https://github.com/apache/datafusion/pull/20672#discussion_r2886645657


##########
datafusion/physical-plan/src/spill/spill_pool.rs:
##########
@@ -247,17 +266,15 @@ impl SpillPoolWriter {
 
 impl Drop for SpillPoolWriter {
     fn drop(&mut self) {
-        let mut shared = self.shared.lock();
-
-        shared.active_writer_count -= 1;
-        let is_last_writer = shared.active_writer_count == 0;
-
-        if !is_last_writer {
+        if !self.writer_count.is_last() {

Review Comment:
   Actually this is also a race... 
   Thread A: is_last() → count is 2 → false → skip finalization
   Thread B: is_last() → count is 2 → false → skip finalization
   Thread A: WriterCount::drop → count becomes 1
   Thread B: WriterCount::drop → count becomes 0
   



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