mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-20 18:04:19 +01:00
fix bug - continue checkpoint as usual even if frames range is degenerate
This commit is contained in:
@@ -1552,21 +1552,6 @@ impl WalFile {
|
|||||||
max_frame = max_frame.min(upper_bound);
|
max_frame = max_frame.min(upper_bound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if max_frame <= nbackfills {
|
|
||||||
tracing::debug!(
|
|
||||||
"no need in checkpoint: max_frame={}, nbackfills={}, prev={:?}",
|
|
||||||
max_frame,
|
|
||||||
nbackfills,
|
|
||||||
self.prev_checkpoint
|
|
||||||
);
|
|
||||||
return Ok(IOResult::Done(CheckpointResult {
|
|
||||||
num_attempted: self.prev_checkpoint.num_attempted,
|
|
||||||
num_backfilled: self.prev_checkpoint.num_backfilled,
|
|
||||||
max_frame: nbackfills,
|
|
||||||
maybe_guard: None,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.ongoing_checkpoint.max_frame = max_frame;
|
self.ongoing_checkpoint.max_frame = max_frame;
|
||||||
self.ongoing_checkpoint.min_frame = nbackfills + 1;
|
self.ongoing_checkpoint.min_frame = nbackfills + 1;
|
||||||
let to_checkpoint = {
|
let to_checkpoint = {
|
||||||
|
|||||||
@@ -540,6 +540,9 @@ fn test_wal_upper_bound_truncate() {
|
|||||||
writer.checkpoint(mode).err().unwrap(),
|
writer.checkpoint(mode).err().unwrap(),
|
||||||
LimboError::Busy
|
LimboError::Busy
|
||||||
));
|
));
|
||||||
|
writer
|
||||||
|
.execute("insert into test values (3, 'final')")
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[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();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user