mvcc: add truncate method to logical log

This commit is contained in:
Jussi Saurio
2025-09-24 08:05:53 +03:00
parent 8f33b31c3d
commit b702af8ac0
2 changed files with 15 additions and 0 deletions

View File

@@ -184,4 +184,15 @@ impl LogicalLog {
let c = self.file.sync(completion)?;
Ok(IOResult::IO(IOCompletions::Single(c)))
}
pub fn truncate(&mut self) -> Result<IOResult<()>> {
let completion = Completion::new_trunc(move |result| {
if let Err(err) = result {
tracing::error!("logical_log_truncate failed: {}", err);
}
});
let c = self.file.truncate(0, completion)?;
self.offset = 0;
Ok(IOResult::IO(IOCompletions::Single(c)))
}
}

View File

@@ -31,6 +31,10 @@ impl Storage {
pub fn sync(&self) -> Result<IOResult<()>> {
self.logical_log.write().unwrap().sync()
}
pub fn truncate(&self) -> Result<IOResult<()>> {
self.logical_log.write().unwrap().truncate()
}
}
impl Debug for Storage {