Skip to content

Fix Map#compute deadlock under thread contention - #28

Merged
kanutocd merged 1 commit into
trunkfrom
fix/map-compute-thread-deadlock
Jul 24, 2026
Merged

Fix Map#compute deadlock under thread contention#28
kanutocd merged 1 commit into
trunkfrom
fix/map-compute-thread-deadlock

Conversation

@kanutocd

Copy link
Copy Markdown
Collaborator

Summary

Fix Ratomic::Map#compute deadlocking when multiple Ruby threads contend for the same key.

When an entry is locked by another thread, compute now retries while releasing Ruby's GVL. This allows the thread executing the existing compute block to resume and release the entry lock.

Testing

  • Added a deterministic regression test for concurrent Map#compute calls on the same key
  • Verified the original issue reproduction
  • Ran 100 repeated contention scenarios
  • Full suite: 117 runs, 2,322 assertions, 0 failures, 2 skips
  • cargo check passes

Fixes #27

@kanutocd
kanutocd merged commit 53fced8 into trunk Jul 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deadlock on concurrent Map#compute when using multiple threads

1 participant