You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: skip empty ranges in optimistic conflict checks - #353
An optimistic write transaction can read an empty range and then panic at commit if another transaction has written to the same keyspace. The read returns an empty iterator, but conflict detection passes the recorded bounds to BTreeSet::range, which panics on reversed bounds or equal excluded bounds.
Skip recording ranges that cannot contain a key. An inclusive single-key range still tracks concurrent inserts, even when the key is absent from the snapshot.
Validation:
The regression panics at commit on main and passes with the fix, including the concurrent-insert control case.
cargo test --all-targets (133 passed, 1 ignored) and cargo test --doc (86 passed).
cargo +1.90.0 test --lib tx_ssi_empty_range, cargo fmt --all -- --check, and cargo clippy.
Summary by CodeRabbit
Bug Fixes
Empty bounded range reads no longer cause conflicts with concurrent insertions. Inclusive singleton ranges over absent keys still detect conflicts.
No actionable comments were generated in the recent review.
Walkthrough
The conflict manager now skips recording bounded ranges that are empty. Tests cover reversed bounds, equal exclusive bounds, and an inclusive singleton range during concurrent insertion.
mark_range skips bounded ranges when inclusive endpoints are reversed or when either endpoint is exclusive and the lower bound is greater than or equal to the upper bound.
Test concurrent insertion conflicts src/tx/optimistic/write_tx.rs
Tests confirm that reversed inclusive bounds and equal exclusive bounds do not conflict with concurrent insertion. An inclusive singleton range over an absent key does conflict.
This change fixes a commit-time panic when an optimistic transaction reads an empty range, and it keeps conflict detection for single-key ranges. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: empty ranges are skipped in the optimistic conflict checks. The raw summary says mark_range now returns without recording a read for empty bounded ranges, and the obje…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: empty ranges are skipped in the optimistic conflict checks. The raw summary says mark_range now returns without recording a read for empty bounded ranges, and the objectives describe the panic from reversed or equal-exclusive bounds passed to BTreeSet::range. The title is specific and matches the changeset.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 9b208360-d2be-492a-a9bd-13ac6c82d2bf
Commits
Reviewing files that changed from the base of the PR and between 8700604 and 39e9f47.
Files selected for processing: 2
src/tx/optimistic/conflict_manager.rs
src/tx/optimistic/write_tx.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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
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.
An optimistic write transaction can read an empty range and then panic at commit if another transaction has written to the same keyspace. The read returns an empty iterator, but conflict detection passes the recorded bounds to
BTreeSet::range, which panics on reversed bounds or equal excluded bounds.Skip recording ranges that cannot contain a key. An inclusive single-key range still tracks concurrent inserts, even when the key is absent from the snapshot.
Validation:
mainand passes with the fix, including the concurrent-insert control case.cargo test --all-targets(133 passed, 1 ignored) andcargo test --doc(86 passed).cargo +1.90.0 test --lib tx_ssi_empty_range,cargo fmt --all -- --check, andcargo clippy.Summary by CodeRabbit