From d303451876cbfc2af7dce183fb0916fca8d302a0 Mon Sep 17 00:00:00 2001 From: Kim Altintop Date: Mon, 4 Dec 2023 20:15:02 +0100 Subject: [PATCH] Try to fsync message log on drop --- crates/core/src/db/message_log.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/core/src/db/message_log.rs b/crates/core/src/db/message_log.rs index 53d269a82c..f4858a851b 100644 --- a/crates/core/src/db/message_log.rs +++ b/crates/core/src/db/message_log.rs @@ -195,6 +195,14 @@ impl std::fmt::Debug for MessageLog { } } +impl Drop for MessageLog { + fn drop(&mut self) { + if let Err(e) = self.sync_all() { + log::warn!("Unable to fsync on drop: {e}"); + } + } +} + // TODO: do we build the concept of batches into the message log? impl MessageLog { #[tracing::instrument(skip(path))]