From fc88328c05be188ba58bfaa0e5583397bd76f2ce Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Mon, 5 Feb 2024 10:46:28 +0200 Subject: [PATCH] refactor: looks like a deadlock however it's not because the acquire_owned will not capture the environment. better to still grab the semaphore, then execute the acquire. --- pageserver/src/tenant/remote_timeline_client.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pageserver/src/tenant/remote_timeline_client.rs b/pageserver/src/tenant/remote_timeline_client.rs index 2e429ee9bc..e3ad88b44a 100644 --- a/pageserver/src/tenant/remote_timeline_client.rs +++ b/pageserver/src/tenant/remote_timeline_client.rs @@ -942,7 +942,7 @@ impl RemoteTimelineClient { tracing::error!("RemoteTimelineClient::shutdown was cancelled; this should not happen, do not make this into an allowed_error") }); - let fut = { + let sem = { let mut guard = self.upload_queue.lock().unwrap(); let upload_queue = match &mut *guard { UploadQueue::Stopped(_) => return Ok(()), @@ -964,10 +964,10 @@ impl RemoteTimelineClient { self.launch_queued_tasks(upload_queue); } - upload_queue.shutdown_ready.clone().acquire_owned() + upload_queue.shutdown_ready.clone() }; - let res = fut.await; + let res = sem.acquire().await; scopeguard::ScopeGuard::into_inner(sg);