fix bug - continue checkpoint as usual even if frames range is degenerate

This commit is contained in:
Nikita Sivukhin
2025-08-21 17:37:19 +04:00
parent c34d884b6e
commit d7e47c1268
2 changed files with 48 additions and 15 deletions

View File

@@ -540,6 +540,9 @@ fn test_wal_upper_bound_truncate() {
writer.checkpoint(mode).err().unwrap(),
LimboError::Busy
));
writer
.execute("insert into test values (3, 'final')")
.unwrap();
}
#[test]
@@ -579,3 +582,48 @@ fn test_wal_state_checkpoint_seq() {
}
);
}
#[test]
fn test_wal_checkpoint_no_work() {
let db = TempDatabase::new_empty(false);
let writer = db.connect_limbo();
let reader = db.connect_limbo();
writer
.execute("create table test(id integer primary key, value text)")
.unwrap();
// open read txn in order to hold early WAL frames and prevent them from checkpoint
reader.execute("BEGIN").unwrap();
reader.execute("SELECT * FROM test").unwrap();
writer
.execute("insert into test values (1, 'hello')")
.unwrap();
writer
.execute("insert into test values (2, 'turso')")
.unwrap();
writer
.checkpoint(CheckpointMode::Passive {
upper_bound_inclusive: None,
})
.unwrap();
assert!(writer
.checkpoint(CheckpointMode::Truncate {
upper_bound_inclusive: None,
})
.is_err());
writer
.execute("insert into test values (3, 'limbo')")
.unwrap();
let state = writer.wal_state().unwrap();
assert_eq!(
state,
WalState {
checkpoint_seq_no: 0,
max_frame: 5
}
);
reader.execute("SELECT * FROM test").unwrap();
}