mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Fix cache locking to use local namespace locking (#8529)
This commit is contained in:
parent
c9be601988
commit
a8e156d6a5
@ -71,6 +71,9 @@ type cacheObjects struct {
|
||||
// mutex to protect migration bool
|
||||
migMutex sync.Mutex
|
||||
|
||||
// nsMutex namespace lock
|
||||
nsMutex *nsLockMap
|
||||
|
||||
// Object functions pointing to the corresponding functions of backend implementation.
|
||||
NewNSLockFn func(ctx context.Context, bucket, object string) RWLocker
|
||||
GetObjectNInfoFn func(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error)
|
||||
@ -566,9 +569,7 @@ func newServerCacheObjects(ctx context.Context, config cache.Config) (CacheObjec
|
||||
exclude: config.Exclude,
|
||||
migrating: migrateSw,
|
||||
migMutex: sync.Mutex{},
|
||||
NewNSLockFn: func(ctx context.Context, bucket, object string) RWLocker {
|
||||
return globalObjectAPI.NewNSLock(ctx, bucket, object)
|
||||
},
|
||||
nsMutex: newNSLock(false),
|
||||
GetObjectInfoFn: func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) {
|
||||
return newObjectLayerFn().GetObjectInfo(ctx, bucket, object, opts)
|
||||
},
|
||||
@ -589,6 +590,10 @@ func newServerCacheObjects(ctx context.Context, config cache.Config) (CacheObjec
|
||||
return newObjectLayerFn().PutObject(ctx, bucket, object, data, opts)
|
||||
},
|
||||
}
|
||||
c.NewNSLockFn = func(ctx context.Context, bucket, object string) RWLocker {
|
||||
return c.nsMutex.NewNSLock(ctx, nil, bucket, object)
|
||||
}
|
||||
|
||||
if migrateSw {
|
||||
go c.migrateCacheFromV1toV2(ctx)
|
||||
}
|
||||
|
@ -291,6 +291,11 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
||||
// - compression
|
||||
verifyObjectLayerFeatures("gateway "+gatewayName, newObject)
|
||||
|
||||
// Disable safe mode operation, after all initialization is over.
|
||||
globalObjLayerMutex.Lock()
|
||||
globalSafeMode = false
|
||||
globalObjLayerMutex.Unlock()
|
||||
|
||||
// Prints the formatted startup message once object layer is initialized.
|
||||
if !globalCLIContext.Quiet {
|
||||
mode := globalMinioModeGatewayPrefix + gatewayName
|
||||
@ -306,11 +311,6 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
||||
printGatewayStartupMessage(getAPIEndpoints(), gatewayName)
|
||||
}
|
||||
|
||||
// Disable safe mode operation, after all initialization is over.
|
||||
globalObjLayerMutex.Lock()
|
||||
globalSafeMode = false
|
||||
globalObjLayerMutex.Unlock()
|
||||
|
||||
// Set uptime time after object layer has initialized.
|
||||
globalBootTime = UTCNow()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user