Repository navigation
fix(TC-1277): saturate SpaceSizes decrement - #345
Merged
Merged
Conversation
Contributor
Author
|
APPROVE: see TC-1277 (reviewed exact head 3dda976). One file: decrement_size now floors at 0 via saturating_sub (it was an unchecked subtract: a release-mode wrap or a debug panic); the unused SubAssign import is removed; the unit test covers an over-decrement plus a decrement at 0. No other behaviour change. |
This was referenced Oct 17, 2026
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.
Linear: TC-1277
SpaceSizes::decrement_size(shared by the FS and S3 stores) used an unchecked subtraction. A double remove or accounting drift panics in debug builds and wraps to ~u64::MAX in release, which would make quota checks reject all writes to the space.Change:
*s = s.saturating_sub(size), matching the saturating behaviour in #336. Adds a unit test that removes more than was added and asserts the size floors at 0 (panics with 'attempt to subtract with overflow' without the fix in a debug build).Verification:
cargo test --lib storage,cargo fmt --check,cargo clippy --all-targets -- -D warnings.