Skip to content

Commit

Permalink
Allow to obtain the number of pending checkpoints
Browse files Browse the repository at this point in the history
This is a measure of backpressure: if the number of checkpoints
pendings increases too much it means we're falling behind.

This also make it so that we panic!() when a checkpoint fails.
It's important to fail here because most of the time we don't
know how to recover from a checkpoint having failed.
  • Loading branch information
David Alves committed Aug 22, 2023
1 parent f4b9ccd commit 578f797
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ where
}
}

/// Returns the number of checkpoints that are pending.
#[must_use]
pub fn pending_checkpoints(&self) -> usize {
self.data.checkpoint_sender.len()
}

fn reclaim(
&self,
file: LogFile<M::File>,
Expand Down Expand Up @@ -359,8 +365,11 @@ where
drop(writer);
let mut manager = wal.data.manager.lock();
if let Err(error) = manager.checkpoint_to(entry_id, &mut reader, &wal) {
error!("Checkpointer failed with error: {error:?}. Skipping checkpoint");
continue;
let message = format!(
"Fatal Error: Checkpointer failed with error: {error:?}. Cannot proceed."
);
error!("{}", message);
panic!("{}", message);
}
writer = file_to_checkpoint.lock();
Some(entry_id)
Expand Down

0 comments on commit 578f797

Please sign in to comment.