diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/cluster/controller.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/cluster/controller.rs index 8757b14f78..3ab81d3c17 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/cluster/controller.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/cluster/controller.rs @@ -205,7 +205,7 @@ pub(super) async fn controller( ); let fut = farmer_cache_worker - .run(piece_getter.downgrade()) + .run(piece_getter) .instrument(info_span!("", %cache_group)); async move { diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs index cb7b418929..14acaa5f1e 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs @@ -487,6 +487,9 @@ where let farmer_cache_worker_fut = run_future_in_dedicated_thread( { + // Piece cache worker uses piece getter, while piece getter uses piece cache, which + // piece cache worker depends on. Use weak reference to break the cycle and allow worker + // to exit when last piece cache instance is dropped. let future = farmer_cache_worker.run(piece_getter.downgrade()); move || future