From cd14f6ca94f9cd1b6f379afb64420b8b4b5976b2 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 1 Aug 2025 00:37:22 +0300 Subject: [PATCH] Fix LSN lease background thread with grpc The spawned thread didn't have the tokio runtime active, which lead to this error: ERROR lsn_lease_bg_task{tenant_id=1bb647cb7d3974b52e74f7442fa7d059 timeline_id=cf41456d3202e1c3940cb8f372d160ab lsn=0/1576000}:panic{thread= location=compute_tools/src/lsn_lease.rs:201:5}: there is no reactor running, must be called from the context of a Tokio 1.x runtime Fixes `test_readonly_node_gc` --- compute_tools/src/lsn_lease.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compute_tools/src/lsn_lease.rs b/compute_tools/src/lsn_lease.rs index 6abfea82e0..153ba5a5be 100644 --- a/compute_tools/src/lsn_lease.rs +++ b/compute_tools/src/lsn_lease.rs @@ -28,7 +28,10 @@ pub fn launch_lsn_lease_bg_task_for_static(compute: &Arc) { let compute = compute.clone(); let span = tracing::info_span!("lsn_lease_bg_task", %tenant_id, %timeline_id, %lsn); + + let runtime = tokio::runtime::Handle::current(); thread::spawn(move || { + let _rt_guard = runtime.enter(); let _entered = span.entered(); if let Err(e) = lsn_lease_bg_task(compute, tenant_id, timeline_id, lsn) { // TODO: might need stronger error feedback than logging an warning.