forked from fjall-rs/lsm-tree
-
Notifications
You must be signed in to change notification settings - Fork 1
fix(test): use shared seqno counter in proptest oracle #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
polaz
merged 10 commits into
main
from
feat/#58-feat-extend-prefix-bloom-skipping-to-multi-table-r
Mar 23, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4edfd88
feat: lazy per-table bloom skipping inside RunReader
polaz 903c201
fix(run_reader): 3-phase iteration loop and metrics-aware bloom skip
polaz e5a9212
test: regression test for stale point read after compact cycles
polaz 6ee747f
test: simplify regression to exact proptest replay sequence
polaz 08d7e91
test: narrow regression to minimal failing sequence
polaz 6a60ddb
fix(test): use shared seqno counter per API contract
polaz a82b393
style(test): replace never-loop with iterator chain in oracle
polaz 2beca07
fix(test): use visible_seqno for read seqno in oracle tests
polaz 20b8bbe
refactor(test): rename regression test to match naming convention
polaz 42e6ebc
docs(test): clarify that flush/compact may advance counter
polaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| mod common; | ||
| use lsm_tree::{AbstractTree, Config, SequenceNumberCounter}; | ||
|
|
||
| /// Regression test derived from proptest seed cc 90710f96... | ||
| /// | ||
| /// The original proptest used an independent seqno counter (`let mut seqno = 1`) | ||
| /// that did not advance on flush/compact, violating the API contract which | ||
| /// requires data seqnos to come from the shared `SequenceNumberCounter` passed | ||
| /// to `Config::new`. With independent counters, the tree's internal SuperVersion | ||
| /// seqno advances faster than the data seqno, causing `get_version_for_snapshot` | ||
| /// to return a stale SuperVersion whose memtable misses recent inserts. | ||
| /// | ||
| /// This test uses the shared counter (correct API usage) and verifies the | ||
| /// same operation pattern works correctly. | ||
| #[test] | ||
| fn point_read_after_compact_flush_returns_latest_value() -> lsm_tree::Result<()> { | ||
| let tmpdir = lsm_tree::get_tmp_folder(); | ||
| let seqno = SequenceNumberCounter::default(); | ||
| let visible_seqno = SequenceNumberCounter::default(); | ||
| let tree = Config::new(&tmpdir, seqno.clone(), visible_seqno.clone()).open()?; | ||
| let k = vec![0u8]; | ||
| let v0 = vec![0u8; 8]; | ||
| let v1 = vec![1u8; 8]; | ||
|
|
||
| // No-op compact on empty tree | ||
| let gc = seqno.get(); | ||
| tree.major_compact(common::COMPACTION_TARGET, gc)?; | ||
| // No-op flush on empty memtable | ||
| tree.flush_active_memtable(0)?; | ||
|
|
||
| let s = seqno.next(); | ||
| tree.insert(&k, &v0, s); | ||
| visible_seqno.fetch_max(s + 1); | ||
| tree.flush_active_memtable(0)?; | ||
|
|
||
| let s = seqno.next(); | ||
| tree.insert(&k, &v0, s); | ||
| visible_seqno.fetch_max(s + 1); | ||
|
|
||
| // Triple compact (first one moves L0→L6, next two re-compact L6) | ||
| let gc = seqno.get(); | ||
| tree.major_compact(common::COMPACTION_TARGET, gc)?; | ||
| tree.major_compact(common::COMPACTION_TARGET, gc)?; | ||
| tree.major_compact(common::COMPACTION_TARGET, gc)?; | ||
| // Flush the pending memtable entry | ||
| tree.flush_active_memtable(0)?; | ||
|
|
||
| // Insert+flush cycle | ||
| for _ in 0..3 { | ||
| let s = seqno.next(); | ||
| tree.insert(&k, &v0, s); | ||
| visible_seqno.fetch_max(s + 1); | ||
| tree.flush_active_memtable(0)?; | ||
| } | ||
|
|
||
| // Second major compact | ||
| let gc = seqno.get(); | ||
| tree.major_compact(common::COMPACTION_TARGET, gc)?; | ||
|
|
||
| // Insert + flush after compact (creates L0 table) | ||
| let s = seqno.next(); | ||
| tree.insert(&k, &v0, s); | ||
| visible_seqno.fetch_max(s + 1); | ||
| tree.flush_active_memtable(0)?; | ||
|
|
||
| // Two memtable inserts — last one has v1 | ||
| let s = seqno.next(); | ||
| tree.insert(&k, &v0, s); | ||
| visible_seqno.fetch_max(s + 1); | ||
|
|
||
| let s = seqno.next(); | ||
| tree.insert(&k, &v1, s); | ||
| visible_seqno.fetch_max(s + 1); | ||
|
|
||
| let read_seqno = visible_seqno.get(); | ||
| assert_eq!( | ||
| tree.get(&k, read_seqno)?.as_ref().map(|v| v.to_vec()), | ||
| Some(v1), | ||
| "Point read at seqno={read_seqno} should return v1 (the latest insert)" | ||
| ); | ||
| Ok(()) | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.