Skip to content

Test run for forked PR: Fix ConcurrentHashMap contention#2824

Merged
2 commits merged intomainfrom
conhashmap-fix
Apr 6, 2026
Merged

Test run for forked PR: Fix ConcurrentHashMap contention#2824
2 commits merged intomainfrom
conhashmap-fix

Conversation

@jtduffy
Copy link
Copy Markdown
Contributor

@jtduffy jtduffy commented Apr 6, 2026

Relates to #2816

AIT run

rdara added 2 commits March 31, 2026 12:11
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-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.67%. Comparing base (bfbb4f5) to head (5f7d937).
⚠️ Report is 108 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jtduffy jtduffy closed this pull request by merging all changes into main in 3741c17 Apr 6, 2026
@github-project-automation github-project-automation bot moved this from Triage to Code Complete/Done in Java Engineering Board Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Code Complete/Done

Development

Successfully merging this pull request may close these issues.

3 participants