Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Fix deadlock on task scheduling when VM start fails #164

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions crates/node/src/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ impl Scheduler {
state.task_queue.remove(&task.tx);
}

self.reschedule(&task).await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.state is locked here, but fn reschedule() tried to lock it again, in order to push the task back to queue.

// The task is already pending in program's work queue. Push program ID
// to pending programs queue to wait available resources.
state.pending_programs.push_back((task.tx, task.program_id));
tracing::warn!("task {} rescheduled: {}", task.id.to_string(), err);
continue;
}
Expand Down Expand Up @@ -355,17 +357,6 @@ impl Scheduler {
}
}

async fn reschedule(&self, task: &Task) -> Result<()> {
// The task is already pending in program's work queue. Push program ID
// to pending programs queue to wait available resources.
self.state
.lock()
.await
.pending_programs
.push_back((task.tx, task.program_id));
Ok(())
}

async fn reap_zombies(&self) {
let mut state = self.state.lock().await;

Expand Down
Loading