From 18fc84afb78d8145a476b92979ef388d37241c16 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Tue, 21 Oct 2025 22:03:17 +0800 Subject: [PATCH] fix(grpc/client): clear reconnecting on failure and requeue reconnection after backoff Ensure the reconnecting flag is reset on failed attempts so subsequent retries can proceed, and explicitly trigger a reconnection attempt after the backoff period to keep retrying recovery. --- core/grpc/client/client.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/grpc/client/client.go b/core/grpc/client/client.go index c09cb7f6..cb1511c3 100644 --- a/core/grpc/client/client.go +++ b/core/grpc/client/client.go @@ -817,7 +817,7 @@ func (c *GrpcClient) executeReconnection() { c.Errorf("reconnection failed: %v", err) c.recordFailure() - // Clear reconnecting flag on failure + // Clear reconnecting flag on failure so we can retry c.reconnectMux.Lock() c.reconnecting = false c.reconnectMux.Unlock() @@ -826,6 +826,16 @@ func (c *GrpcClient) executeReconnection() { backoffDuration := c.calculateBackoff() c.Warnf("will retry reconnection after %v backoff", backoffDuration) time.Sleep(backoffDuration) + + // Trigger another reconnection attempt after backoff + // This ensures we keep trying even if network was down during first attempt + c.Debugf("backoff complete, triggering reconnection retry") + select { + case c.reconnect <- struct{}{}: + c.Debugf("reconnection retry triggered") + default: + c.Debugf("reconnection retry already pending") + } } else { c.recordSuccess() c.Infof("reconnection successful - connection state: %s, registered: %v", c.getState(), c.IsRegistered())