nathant27 opened a new pull request, #5010:
URL: https://github.com/apache/texera/pull/5010

   Fixed deadlock happening in AtomicInteger.get_and_set 
(amber/src/main/python/core/util/atomic.py).
   
   Before, get_and_set acquired non-reentrant lock and then accessed value 
property, which attempts to grab the same lock, causing a deadlock.
   
   After the change, get_and_set now accesses the objects self._value property 
directly inside the existing critical section, which avoids the nested lock 
acquisition. 
      -Chose to do the inline change instead of changing to Reentrant lock to 
avoid potentially unnecessary overhead and because it seems like the more 
appropriate way to access in this context, since we're already grabbing the 
lock anyway in get_and_set
   
   ---
   ###Which issue does this fix?
   Fixes #4794 
   ---
   ###How was this PR tested?
   
   Tested before and after with the code given in the issue below, ran through 
a simple script:
   ```
   import threading
   from core.util.thread.atomic import AtomicInteger
   
   a = AtomicInteger(10)
   done = threading.Event()
   
   def attempt():
       a.get_and_set(99)
       done.set()
   
   threading.Thread(target=attempt, daemon=True).start()
   done.wait(timeout=0.5)
   print(done.is_set())  # False — the call never returns
   ```
   BEFORE: prints "done=False"
   AFTER: prints "done=True". Change properly fixes the deadlock in this example
   
   ### Was this PR authored or co-authored using generative AI tooling?
   No
   


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

Reply via email to