Skip to content

[CELEBORN-2276] Fix race condition in MemoryManager.releaseSortMemory#3620

Open
cxzl25 wants to merge 1 commit intoapache:mainfrom
cxzl25:CELEBORN-2276
Open

[CELEBORN-2276] Fix race condition in MemoryManager.releaseSortMemory#3620
cxzl25 wants to merge 1 commit intoapache:mainfrom
cxzl25:CELEBORN-2276

Conversation

@cxzl25
Copy link
Contributor

@cxzl25 cxzl25 commented Mar 9, 2026

What changes were proposed in this pull request?

Use updateAndGet

Why are the changes needed?

reserveSortMemory calls sortMemoryCounter.addAndGet without any synchronized, so the lock in releaseSortMemory doesn't actually protect against races with reserveSortMemory anyway.

Does this PR resolve a correctness bug?

No

Does this PR introduce any user-facing change?

No

How was this patch tested?

GHA

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good

can you please add dedicated unit tests around this piece of code ?
it would be great to have a test that updates the counter using reserveSortMemory and releaseSortMemory from different threads to demostrate the bug and the fix

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.88%. Comparing base (2dd1b7a) to head (b26b906).
⚠️ Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3620      +/-   ##
==========================================
- Coverage   67.13%   66.88%   -0.24%     
==========================================
  Files         357      357              
  Lines       21860    21967     +107     
  Branches     1943     1949       +6     
==========================================
+ Hits        14674    14691      +17     
- Misses       6166     6262      +96     
+ Partials     1020     1014       -6     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants