The GitHub Actions job "License Binary Checker" on texera.git/main has failed.
Run started by GitHub user bobbai00 (triggered by bobbai00).

Head commit for run:
bb795a0c8febbdaecd6878dcbb81498e8b5c0338 / nathant27 <[email protected]>
fix(amber): avoid AtomicInteger.get_and_set deadlock (#5010)

### What changes were proposed in this PR?
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

### Any related issues, documentation, or discussions?
Fixes #4794 

### How was this PR tested?

in src/test/python/core/util/test_atomic.py
test_get_and_set_currently_deadlocks_on_non_reentrant_lock, bug pinned
test
after the fixes now fails on both asserts lines 99 to 106 on removed
test(test_get_and_set_currently_deadlocks_on_non_reentrant_lock)
```
        assert worker.is_alive(), (
            "worker thread exited unexpectedly — get_and_set neither deadlocked 
"
            "nor completed; the test no longer pins the documented bug."
        )
        assert not completed.is_set(), (
            "get_and_set unexpectedly returned — the deadlock bug appears 
fixed; "
            "delete this pinned test along with the xfail below."
        )
```
This is expected behavior because worker should not be alive after
fixing deadlock, and should be completed.

#### 2 changes to test_atomic.py
**REPLACED**
    test_get_and_set_currently_deadlocks_on_non_reentrant_lock
    WITH
    test_get_and_set_does_not_deadlock_on_non_reentrant_lock
- Mostly the same functionality of old test, but instead of checking if
deadlocks, checks if it does not deadlock by asserting "not
worker.is_alive()" and "completed.is_set" from the thread. Basically
just swapped the two asserts at the end

**UPDATED** test_get_and_set_should_return_old_value_and_replace_state
- REMOVED the xfail with strict = true, because now passes


### Was this PR authored or co-authored using generative AI tooling?
No

Report URL: https://github.com/apache/texera/actions/runs/25796842398

With regards,
GitHub Actions via GitBox

Reply via email to