Skip to content

fix: skip empty ranges in optimistic conflict checks - #353

Open
Mike-Animal-Counseling wants to merge 1 commit into
fjall-rs:mainfrom
Mike-Animal-Counseling:fix/optimistic-empty-range
Open

Mike-Animal-Counseling wants to merge 1 commit into
fjall-rs:mainfrom
Mike-Animal-Counseling:fix/optimistic-empty-range

Conversation

@Mike-Animal-Counseling

@Mike-Animal-Counseling Mike-Animal-Counseling commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Changes: Optimistic transaction range reads

Layer / File(s) Summary
Skip empty bounded ranges
src/tx/optimistic/conflict_manager.rs
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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 39e9f

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • 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.

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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