Skip to content

Commit

Permalink
fix: unlock TASKS as soon as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
koivunej committed Nov 28, 2022
1 parent afe537f commit 63ed162
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pageserver/src/task_mgr.rs
Expand Up @@ -418,16 +418,18 @@ pub async fn shutdown_tasks(
// FIXME: rewrite this with futures unordered
tokio::task::block_in_place(|| {
let mut victim_tasks = Vec::new();
let tasks = TASKS.lock().unwrap();
for task in tasks.values() {
let task_mut = task.mutable.lock().unwrap();
if (kind.is_none() || Some(task.kind) == kind)
&& (tenant_id.is_none() || task_mut.tenant_id == tenant_id)
&& (timeline_id.is_none() || task_mut.timeline_id == timeline_id)
{
let _ = task.shutdown_tx.send_replace(true);
task.token.cancel();
victim_tasks.push(Arc::clone(task));
{
let tasks = TASKS.lock().unwrap();
for task in tasks.values() {
let task_mut = task.mutable.lock().unwrap();
if (kind.is_none() || Some(task.kind) == kind)
&& (tenant_id.is_none() || task_mut.tenant_id == tenant_id)
&& (timeline_id.is_none() || task_mut.timeline_id == timeline_id)
{
let _ = task.shutdown_tx.send_replace(true);
task.token.cancel();
victim_tasks.push(Arc::clone(task));
}
}
}

Expand Down

0 comments on commit 63ed162

Please sign in to comment.