Skip to content

Commit

Permalink
fix: don't leave pending requests orphan state for a long time
Browse files Browse the repository at this point in the history
If the spawned user workers go to a retired state at once, then there will be no
worker to accept the pending requests for a long time. So we must bring out
their semaphore permits while going to a retired state so the pooler can create
a fresh user worker.
  • Loading branch information
nyannyacha committed Jan 10, 2024
1 parent 04c59c6 commit 63aff04
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/base/src/rt_worker/worker_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,19 @@ impl WorkerPool {
}

fn retire(&mut self, key: &Uuid) {
if let Some(profile) = self.user_workers.get(key) {
if let Some(profile) = self.user_workers.get_mut(key) {
let registry = self
.active_workers
.get_mut(&profile.service_path)
.expect("registry must be initialized at this point");

let _ = profile.permit.take();
let (notify_tx, _) = registry.notify_pair.clone();

for _ in 0..notify_tx.receiver_count() {
let _ = notify_tx.send(None);
}

if registry.workers.contains(key) {
registry.workers.remove(key);
}
Expand Down

0 comments on commit 63aff04

Please sign in to comment.