Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions rust/lance/src/dataset/mem_wal/write.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright The Lance Authors

Expand Down Expand Up @@ -8985,6 +8985,7 @@

// Seeded at open, before anything has been written.
assert_no_drift(&writer, "open").await;
let initial_generation = writer.memtable_stats().await.unwrap().generation;

for i in 0..24 {
writer
Expand All @@ -8995,15 +8996,19 @@
}

// Freezes happened above; make sure at least one did, or this test proves
// nothing about the freeze path.
// nothing about the freeze path. Generation is monotonic, unlike the
// current frozen handle count, which zero grace removes on flush commit.
let after_puts = writer.memtable_stats().await.unwrap();
assert!(
writer.memory().frozen_bytes() > 0
|| writer.memtable_stats().await.unwrap().frozen_count > 0,
"the loop must have frozen at least once for this to cover freeze"
after_puts.generation > initial_generation,
"the loop must have advanced the active generation to cover freeze: \
{initial_generation} -> {}",
after_puts.generation
);

writer.wait_for_flush_drain().await.unwrap();
assert_no_drift(&writer, "flush drain").await;
let after_drain = writer.memtable_stats().await.unwrap();

// A long grace keeps the flushed handles in the read view and a zero
// grace evicts them on commit — two different publish paths. Either way
Expand All @@ -9013,6 +9018,17 @@
0,
"flushed memtables are reclaimable and must stop metering (grace {grace:?})"
);
if grace.is_zero() {
assert_eq!(
after_drain.frozen_count, 0,
"zero grace must evict flushed handles on commit"
);
} else {
assert!(
after_drain.frozen_count > 0,
"long grace must retain flushed handles in the read view"
);
}

for i in 24..32 {
writer
Expand Down
Loading