SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
avoid repeated grpc connection creation
Chris Luaebe39a80388
diff --git a/weed/pb/grpc_client_server.go b/weed/pb/grpc_client_server.goindex c4e35618f0..ef22aededc 100644--- a/weed/pb/grpc_client_server.go+++ b/weed/pb/grpc_client_server.go@@ -86,13 +86,15 @@ func WithCachedGrpcClient(fn func(*grpc.ClientConn) error, address string, optserr := fn(existingConnection)if err != nil {grpcClientsLock.Lock()- delete(grpcClients, address)+ // delete(grpcClients, address)grpcClientsLock.Unlock()- existingConnection.Close()+ // println("closing existing connection to", existingConnection.Target())+ // existingConnection.Close()}return err}+ println(" dialing to", address, "...")grpcConnection, err := GrpcDial(context.Background(), address, opts...)if err != nil {grpcClientsLock.Unlock()@@ -105,9 +107,10 @@ func WithCachedGrpcClient(fn func(*grpc.ClientConn) error, address string, optserr = fn(grpcConnection)if err != nil {grpcClientsLock.Lock()- delete(grpcClients, address)+ // delete(grpcClients, address)grpcClientsLock.Unlock()- grpcConnection.Close()+ // println("closing created new connection to", grpcConnection.Target())+ // grpcConnection.Close()}return errdiff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.goindex f73853c78a..4f8e0d5efe 100644--- a/weed/wdclient/masterclient.go+++ b/weed/wdclient/masterclient.go@@ -121,6 +121,9 @@ func (mc *MasterClient) tryConnectToMaster(master string) (nextHintedLeader stri}func (mc *MasterClient) WithClient(fn func(client master_pb.SeaweedClient) error) error {+ for mc.currentMaster == "" {+ time.Sleep(3 * time.Second)+ }return pb.WithMasterClient(mc.currentMaster, mc.grpcDialOption, func(client master_pb.SeaweedClient) error {return fn(client)})