Skip to content

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.

Fix deadlock in worker client Connect() method (#7350)

Chris Lu34054ed91031
diff --git a/weed/worker/client.go b/weed/worker/client.go
index a90eac6430..9066afdf3d 100644
--- a/weed/worker/client.go
+++ b/weed/worker/client.go
@@ -74,11 +74,12 @@ func NewGrpcAdminClient(adminAddress string, workerID string, dialOption grpc.Di
// Connect establishes gRPC connection to admin server with TLS detection
func (c *GrpcAdminClient) Connect() error {
c.mutex.Lock()
- defer c.mutex.Unlock()
-
if c.connected {
+ c.mutex.Unlock()
return fmt.Errorf("already connected")
}
+ // Release lock before calling attemptConnection which needs to acquire locks internally
+ c.mutex.Unlock()
// Always start the reconnection loop, even if initial connection fails
go c.reconnectionLoop()