From b0e1cffc1610a3306dc977286c5af6eea8acbd28 Mon Sep 17 00:00:00 2001 From: smallnest Date: Tue, 2 Apr 2024 13:49:35 +0800 Subject: [PATCH] lilou-1294 fix the issue that the sticky client is closed --- client/xclient.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/xclient.go b/client/xclient.go index 68e97cde..c8ade474 100644 --- a/client/xclient.go +++ b/client/xclient.go @@ -245,6 +245,10 @@ func filterByStateAndGroup(group string, servers map[string]string) { // selects a client from candidates base on c.selectMode func (c *xClient) selectClient(ctx context.Context, servicePath, serviceMethod string, args interface{}) (string, RPCClient, error) { c.mu.Lock() + if c.option.Sticky && c.stickyRPCClient.IsClosing() || c.stickyRPCClient.IsShutdown() { + c.stickyRPCClient = nil + } + if c.option.Sticky && c.stickyRPCClient != nil { c.mu.Unlock() return c.stickyK, c.stickyRPCClient, nil