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.

s3: fix potencial iam identities data race

Bl1tz235018b22f3687
diff --git a/weed/s3api/auth_credentials.go b/weed/s3api/auth_credentials.go
index 78b82589ef..8d05f2a039 100644
--- a/weed/s3api/auth_credentials.go
+++ b/weed/s3api/auth_credentials.go
@@ -5,6 +5,7 @@ import (
"net/http"
"os"
"strings"
+ "sync"
"github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/glog"
@@ -23,6 +24,8 @@ type Iam interface {
}
type IdentityAccessManagement struct {
+ m sync.Mutex
+
identities []*Identity
domain string
}
@@ -131,9 +134,12 @@ func (iam *IdentityAccessManagement) loadS3ApiConfiguration(config *iam_pb.S3Api
}
identities = append(identities, t)
}
-
+ iam.m.Lock()
+
// atomically switch
iam.identities = identities
+
+ iam.m.Unlock()
return nil
}