From 5c937f260a6439ee9d6b3973a80e0ec087fe3d1b Mon Sep 17 00:00:00 2001 From: LesnyRumcajs Date: Thu, 24 Jul 2025 11:50:07 +0200 Subject: [PATCH] fix: don't run GC on stateless nodes --- CHANGELOG.md | 2 ++ src/daemon/mod.rs | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 797db9ca282c..e769382ac109 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ ### Fixed +- [#5863](https://github.com/ChainSafe/forest/pull/5863) Fixed needless GC runs on a stateless node. + ## Forest v0.28.0 "Denethor's Folly" This is a non-mandatory release recommended for all node operators. It includes numerous fixes and quality-of-life improvements for development and archival snapshot operations. It also includes a memory leak fix that would surface on long-running nodes. diff --git a/src/daemon/mod.rs b/src/daemon/mod.rs index 2688152231d5..49d4a2b1b472 100644 --- a/src/daemon/mod.rs +++ b/src/daemon/mod.rs @@ -508,11 +508,16 @@ pub(super) async fn start( .set(snap_gc.clone()) .ok() .context("failed to set GLOBAL_SNAPSHOT_GC")?; - tokio::task::spawn({ - let snap_gc = snap_gc.clone(); - async move { snap_gc.event_loop().await } - }); - if !opts.no_gc { + + // If the node is stateless, GC shouldn't get triggered even on demand. + if !opts.stateless { + tokio::task::spawn({ + let snap_gc = snap_gc.clone(); + async move { snap_gc.event_loop().await } + }); + } + // GC shouldn't run periodically if the node is stateless or if the user has disabled it. + if !opts.no_gc && !opts.stateless { tokio::task::spawn({ let snap_gc = snap_gc.clone(); async move { snap_gc.scheduler_loop().await }