diff --git a/crates/core/src/host/host_controller.rs b/crates/core/src/host/host_controller.rs index b5577c8e7e7..d8e994790ca 100644 --- a/crates/core/src/host/host_controller.rs +++ b/crates/core/src/host/host_controller.rs @@ -548,6 +548,12 @@ impl HostController { info!("replica={replica_id} database={database_identity} exiting module"); module.exit().await; + // Abort background tasks before shutting down durability. + // These tasks may call `with_auto_commit`, which calls `request_durability`. + // If the durability channel is already closed, that panics. + host.view_cleanup_task.abort(); + host.disk_metrics_recorder_task.abort(); + host.tx_metrics_recorder_task.abort(); let db = &module.replica_ctx().relational_db; info!("replica={replica_id} database={database_identity} exiting database"); db.shutdown().await;