Skip to content

Commit 63aff04

Browse files
committed
fix: don't leave pending requests orphan state for a long time
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.
1 parent 04c59c6 commit 63aff04

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/base/src/rt_worker/worker_pool.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,19 @@ impl WorkerPool {
534534
}
535535

536536
fn retire(&mut self, key: &Uuid) {
537-
if let Some(profile) = self.user_workers.get(key) {
537+
if let Some(profile) = self.user_workers.get_mut(key) {
538538
let registry = self
539539
.active_workers
540540
.get_mut(&profile.service_path)
541541
.expect("registry must be initialized at this point");
542542

543+
let _ = profile.permit.take();
544+
let (notify_tx, _) = registry.notify_pair.clone();
545+
546+
for _ in 0..notify_tx.receiver_count() {
547+
let _ = notify_tx.send(None);
548+
}
549+
543550
if registry.workers.contains(key) {
544551
registry.workers.remove(key);
545552
}

0 commit comments

Comments
 (0)