fix: don't join Drop cleanup thread — prevents deadlock in tokio tests

The Drop impl spawned a thread with a new tokio runtime and called
.join(), which blocked the test thread. The spawned thread's block_on
deadlocked when pool.close() tried to communicate with connections
owned by the outer tokio runtime. Removing .join() makes cleanup
fire-and-forget, avoiding the deadlock.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
master
oabrivard 3 months ago
parent 243558b950
commit a0a8f72caa

@ -475,8 +475,9 @@ impl TestApp {
impl Drop for TestApp { impl Drop for TestApp {
fn drop(&mut self) { fn drop(&mut self) {
// Best-effort synchronous cleanup. The `cleanup()` async method is // Fire-and-forget cleanup. Don't .join() — that deadlocks when
// preferred, but this catches cases where it wasn't called. // running inside a tokio runtime (the spawned thread's block_on
// conflicts with the existing runtime's connection pool).
let admin_pool = self.admin_pool.clone(); let admin_pool = self.admin_pool.clone();
let db_name = self.db_name.clone(); let db_name = self.db_name.clone();
let test_pool = self.pool.clone(); let test_pool = self.pool.clone();
@ -502,8 +503,7 @@ impl Drop for TestApp {
.execute(format!("DROP DATABASE IF EXISTS \"{}\"", db_name).as_str()) .execute(format!("DROP DATABASE IF EXISTS \"{}\"", db_name).as_str())
.await; .await;
}); });
}) });
.join() // Don't join — let the cleanup thread run independently
.ok();
} }
} }

Loading…
Cancel
Save