Skip to content

Commit

Permalink
Update to ensure that drop issues a warning in debug mode instead of …
Browse files Browse the repository at this point in the history
…universally.
  • Loading branch information
hoytak committed Dec 18, 2024
1 parent 286e663 commit 7f4ffea
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions mdb_shard/src/shard_file_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
}
}
Expand Down

0 comments on commit 7f4ffea

Please sign in to comment.