From 3ebbd25a4babb7f45cd4716ddbcdcb4e721ecbac Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 22 Dec 2025 00:16:03 -0800 Subject: [PATCH] fix: prevent deadlock when stream error occurs - make cmds send non-blocking If managerLoop is blocked (e.g., waiting on regWait), a blocking send to cmds will deadlock handleIncoming. Make the send non-blocking to prevent this. --- weed/worker/client.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/weed/worker/client.go b/weed/worker/client.go index 7d5a8a8b2..963771a6b 100644 --- a/weed/worker/client.go +++ b/weed/worker/client.go @@ -446,8 +446,12 @@ func handleIncoming( default: } - // Report the failure as a command to the managerLoop (blocking) - cmds <- grpcCommand{action: ActionStreamError, data: err} + // Report the failure as a command to the managerLoop (non-blocking to prevent deadlock) + select { + case cmds <- grpcCommand{action: ActionStreamError, data: err}: + default: + glog.V(2).Infof("Manager busy, stream error not queued: %v", err) + } // Exit the main handler loop glog.V(1).Infof("INCOMING HANDLER STOPPED: Worker %s stopping incoming handler due to stream error", workerID)