Fix non-atomic reads in PDisk quota calculation#32206
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes thread safety issues in PDisk quota calculation by ensuring atomic reads of shared variables and preventing division by zero.
Changes:
- Added
AtomicGet()calls forHardLimitandFreefields in thePrint()method to ensure thread-safe reads - Modified
EstimateSpaceColor()to readHardLimitatomically into a local variable and check for zero before division
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| *occupancy = hardLimit ? (double)(hardLimit - newFree) / hardLimit : 1.0; | ||
|
|
There was a problem hiding this comment.
Lines 154-158 compute the occupancy value, but line 160 unconditionally overwrites it, making the preceding calculation dead code. Either remove lines 154-158 or remove line 160. If keeping line 160, note that it lacks the std::max protection from line 155 which prevents negative numerators when newFree exceeds hardLimit.
| *occupancy = hardLimit ? (double)(hardLimit - newFree) / hardLimit : 1.0; |
|
🟢 |
9136fef to
4ce38a0
Compare
|
⚪ ⚪ DetailsYa make output | Test bloat | Test bloat
⚪ Ya make output | Test bloat | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
Backport results: |
Changelog entry
Read atomic variables in PDisk QuotaTracker with a proper method.
Fixes #31995
Changelog category