ankurdave opened a new pull request #32625:
URL: https://github.com/apache/spark/pull/32625


   ### What changes were proposed in this pull request?
   
   When a memory reservation triggers a self-spill, 
`ExecutionMemoryPool#releaseMemory()` will immediately notify waiting tasks 
that memory has been freed. If there are any waiting tasks with less than 1/2N 
of the memory pool, they may acquire the newly-freed memory before the current 
task has a chance to do so. This will cause the original memory reservation to 
fail. If the initial spill did not release all available memory, the 
reservation could have been satisfied by asking it to spill again.
   
   This PR adds logic to TaskMemoryManager to detect this case and retry.
   
   ### Why are the changes needed?
   
   This bug affects queries with a MemoryConsumer that can spill part of its 
memory, such as BytesToBytesMap. If the MemoryConsumer is using all available 
memory and there is a waiting task, then attempting to acquire more memory on 
the MemoryConsumer will trigger a partial self-spill. However, because the 
waiting task gets priority, the attempt to acquire memory will fail even if it 
could have been satisfied by another spill.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added a test to MemoryManagerSuite that previously failed and now passes.


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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to