Test run for forked PR: Fix ConcurrentHashMap contention#2824
Merged
2 commits merged intomainfrom Apr 6, 2026
Merged
Conversation
Replace computeIfAbsent() with putIfAbsent pattern to avoid bin-level locking during value creation. This prevents thread contention issues where threads get stuck in ConcurrentHashMap.helpTransfer() under high concurrency scenarios. The fix uses a double-check pattern: 1. Fast path check with get() 2. Create value outside any lock 3. Atomic putIfAbsent - only one thread wins Trade-off: Under race conditions, multiple threads may create extension instances, but only one wins. This is safe because valueLoader creates empty/stateless instances. This issue was observed in production environments with high thread counts causing application hangs due to ConcurrentHashMap internal contention. Ref: NewRelic Support Case #00311074
Tests verify: - Basic get/remove extension functionality - High concurrency access to same instance key - High concurrency access with different instance keys - Contention scenario with slow value loader These tests confirm the putIfAbsent pattern handles concurrent access without causing thread contention issues.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2824 +/- ##
============================================
+ Coverage 70.32% 70.67% +0.34%
- Complexity 10457 10621 +164
============================================
Files 873 881 +8
Lines 42287 42918 +631
Branches 6419 6488 +69
============================================
+ Hits 29740 30332 +592
- Misses 9645 9664 +19
- Partials 2902 2922 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #2816
AIT run