venkata91 opened a new pull request #24265: [SPARK-27338][Core] Fix deadlock in 
UnsafeExternalSorter.SpillableIterator when locking both 
UnsafeExternalSorter.SpillableIterator and TaskMemoryManager
URL: https://github.com/apache/spark/pull/24265
 
 
   ## What changes were proposed in this pull request?
   
   In `UnsafeExternalSorter.SpillableIterator#loadNext()` takes lock on the 
`UnsafeExternalSorter` and calls `freePage` once the `lastPage` is consumed 
which needs to take a lock on `TaskMemoryManager`. At the same time, there can 
be another MemoryConsumer using `UnsafeExternalSorter` as part of sorting can 
try to `allocatePage` needs to get lock on `TaskMemoryManager` which can cause 
spill to happen which requires lock on `UnsafeExternalSorter` again causing 
deadlock. This is a classic deadlock situation happening similar to the 
SPARK-26265.
   
   To fix this, we can move the `freePage` call in `loadNext` outside of 
`Synchronized` block similar to the fix in SPARK-26265
   
   ## How was this patch tested?
   
   Manual tests were done and will also try to add a test.
   

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


With regards,
Apache Git Services

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

Reply via email to