Browse Source

Use non-blocking async pattern in handleOutgoing error reporting

Refactor handleStreamError to use non-blocking send with async fallback goroutine,
matching the pattern used in handleIncoming. This allows handleOutgoing to exit
immediately when errors occur rather than blocking for up to 2 seconds, improving
responsiveness and consistency across handlers.
pull/7838/head
Chris Lu 2 months ago
parent
commit
acbb483b31
  1. 13
      weed/worker/client.go

13
weed/worker/client.go

@ -365,8 +365,17 @@ func handleOutgoing(
glog.Errorf("Failed to send message to admin: %v", err)
select {
case cmds <- grpcCommand{action: ActionStreamError, data: err}:
case <-time.After(2 * time.Second):
glog.Warningf("Failed to send stream error to manager from outgoing handler, channel blocked: %v", err)
// Successfully queued
default:
// Manager busy, queue asynchronously to avoid blocking
glog.V(2).Infof("Manager busy, queuing stream error asynchronously from outgoing handler: %v", err)
go func(e error) {
select {
case cmds <- grpcCommand{action: ActionStreamError, data: e}:
case <-time.After(2 * time.Second):
glog.Warningf("Failed to send stream error to manager from outgoing handler, channel blocked: %v", e)
}
}(err)
}
}
}

Loading…
Cancel
Save