mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-22 21:59:59 +00:00
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=<unnamed> 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`
This commit is contained in:
@@ -28,7 +28,10 @@ pub fn launch_lsn_lease_bg_task_for_static(compute: &Arc<ComputeNode>) {
|
|||||||
let compute = compute.clone();
|
let compute = compute.clone();
|
||||||
|
|
||||||
let span = tracing::info_span!("lsn_lease_bg_task", %tenant_id, %timeline_id, %lsn);
|
let span = tracing::info_span!("lsn_lease_bg_task", %tenant_id, %timeline_id, %lsn);
|
||||||
|
|
||||||
|
let runtime = tokio::runtime::Handle::current();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
let _rt_guard = runtime.enter();
|
||||||
let _entered = span.entered();
|
let _entered = span.entered();
|
||||||
if let Err(e) = lsn_lease_bg_task(compute, tenant_id, timeline_id, lsn) {
|
if let Err(e) = lsn_lease_bg_task(compute, tenant_id, timeline_id, lsn) {
|
||||||
// TODO: might need stronger error feedback than logging an warning.
|
// TODO: might need stronger error feedback than logging an warning.
|
||||||
|
|||||||
Reference in New Issue
Block a user