Add is_full method to checkpoint batch

This commit is contained in:
PThorpe92
2025-07-29 22:07:49 -04:00
parent 693b71449e
commit ade1c182de
2 changed files with 13 additions and 8 deletions

View File

@@ -963,7 +963,10 @@ pub fn write_pages_vectored(
}
#[instrument(skip_all, level = Level::DEBUG)]
pub fn begin_sync(db_file: Arc<dyn DatabaseStorage>, syncing: Rc<RefCell<bool>>) -> Result<()> {
pub fn begin_sync(
db_file: Arc<dyn DatabaseStorage>,
syncing: Rc<RefCell<bool>>,
) -> Result<Completion> {
assert!(!*syncing.borrow());
*syncing.borrow_mut() = true;
let completion = Completion::new_sync(move |_| {

View File

@@ -415,6 +415,9 @@ impl Batch {
items: BTreeMap::new(),
}
}
fn is_full(&self) -> bool {
self.items.len() >= CKPT_BATCH_PAGES
}
fn add_to_batch(&mut self, scratch: &PageRef, pool: &Arc<BufferPool>) {
let (id, buf_clone) = unsafe {
let inner = &*scratch.inner.get();
@@ -1560,13 +1563,12 @@ impl WalFile {
// In Restart or Truncate mode, we need to restart the log over and possibly truncate the file
// Release all locks and return the current num of wal frames and the amount we backfilled
CheckpointState::Done => {
turso_assert!(
self.ongoing_checkpoint
.pending_flush
.as_ref()
.is_some_and(|pf| pf.done.load(Ordering::Relaxed)),
"checkpoint pending flush must have finished"
);
if let Some(pf) = self.ongoing_checkpoint.pending_flush.as_ref() {
turso_assert!(
pf.done.load(Ordering::Relaxed),
"checkpoint pending flush must have finished"
);
}
let mut checkpoint_result = {
let shared = self.get_shared();
let current_mx = shared.max_frame.load(Ordering::SeqCst);