From 2150289442f1f84903ada4514807c5c397545440 Mon Sep 17 00:00:00 2001 From: "steve.wei" Date: Sat, 8 Jun 2024 00:13:03 +0800 Subject: [PATCH] fix: Ensure that the clientAddress is unique (#5655) --- weed/server/master_grpc_server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/weed/server/master_grpc_server.go b/weed/server/master_grpc_server.go index 0a7bd5ef2..088e91be8 100644 --- a/weed/server/master_grpc_server.go +++ b/weed/server/master_grpc_server.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/google/uuid" "github.com/seaweedfs/seaweedfs/weed/cluster" "net" "sort" @@ -260,7 +261,12 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ return ms.informNewLeader(stream) } - peerAddress := pb.ServerAddress(req.ClientAddress) + clientAddress := req.ClientAddress + // Ensure that the clientAddress is unique. + if clientAddress == "" { + clientAddress = uuid.New().String() + } + peerAddress := pb.ServerAddress(clientAddress) // buffer by 1 so we don't end up getting stuck writing to stopChan forever stopChan := make(chan bool, 1)