Skip to content

[Storage] Make three TierManager fields thread-safe for SonarCloud's reliability gate - #19228

Open
chrisdutz wants to merge 2 commits into
masterfrom
fix/tier-manager-thread-safe-fields
Open

chrisdutz wants to merge 2 commits into
masterfrom
fix/tier-manager-thread-safe-fields

Conversation

@chrisdutz

Copy link
Copy Markdown
Contributor

Description

SonarCloud's quality gate currently fails for pull requests with new_reliability_rating = 2 (B, the limit is A). The rating comes from three java:S3077 findings in TierManager, which recent master commits (#19126, #19151, #19161) touched, not from the pull requests themselves (e.g. #19108):

Field Finding Fix
folderManagers (line 65) a Map published through a volatile field is not thread-safe AtomicReference holding an unmodifiable map that rebuildFolders() replaces as a whole
tierDiskTotalSpace (line 78) a long[] behind a volatile field AtomicReference<long[]>, replaced as a whole; getTierDiskTotalSpace() reads it once and returns a copy
TierFolderManager.manager (line 236) a mutable FolderManager behind a volatile field AtomicReference<FolderManager>, set by the memoized supplier

Behavior is unchanged: hasSpaceForRecovery() still compares the map it read before the check with the one published afterwards, so a rebuild in between still prevents the recovery.

Tests

TierManagerTest, TierManagerDiskFullReloadTest, SnapshotLoaderDiskFullReloadTest, IoTDBSnapshotTest, TTLTest: 22 tests pass (1 skipped); spotless:check passes.

🤖 Generated with Claude Code

…reliability gate

SonarCloud reports java:S3077 for three volatile fields in TierManager that hold a mutable map,
an array and a mutable FolderManager. They are now AtomicReferences: folderManagers holds an
unmodifiable map that rebuildFolders() replaces as a whole, tierDiskTotalSpace an array that is
replaced as a whole and copied once in getTierDiskTotalSpace(), and TierFolderManager.manager the
FolderManager created by the memoized supplier. The identity check in hasSpaceForRecovery() still
compares the map read before the check with the one published after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.89%. Comparing base (6e7448d) to head (39f8a7b).

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #19228   +/-   ##
=========================================
  Coverage     48.88%   48.89%           
  Complexity      689      689           
=========================================
  Files          5588     5588           
  Lines        413444   413448    +4     
  Branches      54537    54537           
=========================================
+ Hits         202128   202150   +22     
+ Misses       211316   211298   -18     

☔ View full report in Codecov by Harness.
📢 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.

…s returned as a copy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant