From ae3ed46796d6b9fa62bec737458eb3da6c0e2ca2 Mon Sep 17 00:00:00 2001 From: Robert Escriva Date: Tue, 24 Jun 2025 20:39:39 -0700 Subject: [PATCH] [BUG] Do not leak tokio tasks in the log service. The background tasks of wal3 were leaked because the log service was not calling shutdown when dropping a log. This PR corrects that. --- rust/wal3/src/writer.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rust/wal3/src/writer.rs b/rust/wal3/src/writer.rs index e72390599b1..7faa9d25115 100644 --- a/rust/wal3/src/writer.rs +++ b/rust/wal3/src/writer.rs @@ -381,6 +381,15 @@ impl std::fmt::Debug for LogWriter { } } +impl Drop for LogWriter { + fn drop(&mut self) { + let mut inner = self.inner.lock().unwrap(); + if let Some(writer) = inner.writer.as_mut() { + writer.shutdown(); + } + } +} + /////////////////////////////////////////// OnceLogWriter ////////////////////////////////////////// /// OnceLogWriter writes to a log once until contention is discovered. It must then be thrown away