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:
Chris Lu
2026-03-27 12:53:11 -07:00
parent 0f5c6a8ae0
commit 98fcda66f2
2 changed files with 3 additions and 2 deletions
+1 -2
View File
@@ -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 {
+2
View File
@@ -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