diff --git a/src/journal/mod.rs b/src/journal/mod.rs index 05a4611b..2d07599a 100644 --- a/src/journal/mod.rs +++ b/src/journal/mod.rs @@ -28,21 +28,6 @@ pub struct Journal { pub shards: Sharded, } -impl Drop for Journal { - fn drop(&mut self) { - log::trace!("Dropping Journal, trying to flush"); - - match self.flush(PersistMode::SyncAll) { - Ok(()) => { - log::trace!("Flushed journal successfully"); - } - Err(e) => { - log::error!("Flush error on drop: {e:?}"); - } - } - } -} - impl Journal { pub fn recover_memtables>( path: P, diff --git a/src/keyspace.rs b/src/keyspace.rs index 16aa2fd0..6d0551cf 100644 --- a/src/keyspace.rs +++ b/src/keyspace.rs @@ -73,8 +73,19 @@ pub struct KeyspaceInner { impl Drop for KeyspaceInner { fn drop(&mut self) { + log::trace!("Dropping Keyspace, trying to flush journal"); + self.stop_signal.send(); + match self.journal.flush(PersistMode::SyncAll) { + Ok(()) => { + log::trace!("Flushed journal successfully"); + } + Err(e) => { + log::error!("Flush error on drop: {e:?}"); + } + } + while self .active_background_threads .load(std::sync::atomic::Ordering::Relaxed)