mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
make LockClient persistent on S3ApiServer
Avoid per-request allocation by initializing the lock client once at server startup. The gRPC connections were already pooled; this eliminates the remaining struct allocation overhead.
This commit is contained in:
@@ -1854,8 +1854,7 @@ func (s3a *S3ApiServer) lockAndRecheckConditionalHeaders(r *http.Request, bucket
|
||||
}
|
||||
|
||||
lockKey := s3a.toFilerPath(bucket, object)
|
||||
lockClient := cluster.NewLockClient(s3a.option.GrpcDialOption, s3a.option.Filers[0])
|
||||
lock := lockClient.NewShortLivedLock(lockKey, fmt.Sprintf("s3-cond-%d", s3a.randomClientId))
|
||||
lock := s3a.lockClient.NewShortLivedLock(lockKey, fmt.Sprintf("s3-cond-%d", s3a.randomClientId))
|
||||
|
||||
entry, err := s3a.resolveObjectEntry(bucket, object)
|
||||
if err != nil {
|
||||
|
||||
@@ -82,6 +82,7 @@ type S3ApiServer struct {
|
||||
embeddedIam *EmbeddedIamApi // Embedded IAM API server (when enabled)
|
||||
stsHandlers *STSHandlers // STS HTTP handlers for AssumeRoleWithWebIdentity
|
||||
cipher bool // encrypt data on volume servers
|
||||
lockClient *cluster.LockClient
|
||||
}
|
||||
|
||||
func NewS3ApiServer(router *mux.Router, option *S3ApiServerOption) (s3ApiServer *S3ApiServer, err error) {
|
||||
@@ -180,6 +181,7 @@ func NewS3ApiServerWithStore(router *mux.Router, option *S3ApiServerOption, expl
|
||||
policyEngine: policyEngine, // Initialize bucket policy engine
|
||||
inFlightDataLimitCond: sync.NewCond(new(sync.Mutex)),
|
||||
cipher: option.Cipher,
|
||||
lockClient: cluster.NewLockClient(option.GrpcDialOption, option.Filers[0]),
|
||||
}
|
||||
|
||||
// Set s3a reference in circuit breaker for upload limiting
|
||||
|
||||
Reference in New Issue
Block a user