From 7f4ffead81b19675b85a410562fb41f299a44eee Mon Sep 17 00:00:00 2001 From: Hoyt Koepke Date: Wed, 18 Dec 2024 16:51:35 -0700 Subject: [PATCH] Update to ensure that drop issues a warning in debug mode instead of universally. --- mdb_shard/src/shard_file_manager.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/mdb_shard/src/shard_file_manager.rs b/mdb_shard/src/shard_file_manager.rs index e2a1acc..1ca3480 100644 --- a/mdb_shard/src/shard_file_manager.rs +++ b/mdb_shard/src/shard_file_manager.rs @@ -27,21 +27,11 @@ struct MDBShardFlushGuard { impl Drop for MDBShardFlushGuard { fn drop(&mut self) { - if self.shard.is_empty() { - return; - } - - if let Some(sd) = &self.session_directory { - // Check if the flushing directory exists. - if !sd.is_dir() { - error!("Error flushing reconstruction data on shutdown: {sd:?} is not a directory or doesn't exist"); - return; + if !self.shard.is_empty() { + // This is only supposed to happen on task cancellations, so we should + if cfg!(debug_assertions) { + eprintln!("[Debug] Warning: Shard dropped while data still present! This is an error outside of task cancellation."); } - - self.flush().unwrap_or_else(|e| { - error!("Error flushing reconstruction data on shutdown: {e:?}"); - None - }); } } }