From 8878a53c551fb55df22b3642db188cbaf494690a Mon Sep 17 00:00:00 2001 From: Harsh Modi Date: Tue, 18 Nov 2025 10:09:26 -0800 Subject: [PATCH] gc: Run gc in a tokio task to not block main async thread --- blade/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blade/main.rs b/blade/main.rs index 7811f7a..b5e2426 100644 --- a/blade/main.rs +++ b/blade/main.rs @@ -345,15 +345,15 @@ cfg_if! { if global.retention.is_none() { continue; } - let Ok(mut db) = global.db_manager.get() else { - tracing::warn!("Failed to get DB handle for cleanup"); - continue; - }; let Some(since) = std::time::SystemTime::now().checked_sub(interval) else { tracing::warn!("Overflow when clean up time"); continue; }; - tracing::info!("Cleanup result: {:#?}", db.delete_invocations_since(&since)); + db::run(global.db_manager.clone(), move |db_mgr| db_mgr.delete_invocations_since(&since)).await.inspect_err(|e| { + tracing::warn!("Failed to mark old invocations for deletion: {e:#?}"); + }).ok().inspect(|count| { + tracing::info!("Marked {} invocations for deletion", count); + }); } }