repl: resync orchestrator to use global shared lock (#16154)

This commit is contained in:
Anis Elleuch 2022-12-01 21:10:09 +01:00 committed by GitHub
parent 71133105d7
commit 641ab24aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2519,23 +2519,12 @@ func (p *ReplicationPool) startResyncRoutine(ctx context.Context, buckets []Buck
}
}
var replicationResyncLockTimeout = newDynamicTimeoutWithOpts(dynamicTimeoutOpts{
timeout: 30 * time.Second,
minimum: 10 * time.Second,
retryInterval: time.Second,
})
// Loads bucket replication resync statuses into memory.
func (p *ReplicationPool) loadResync(ctx context.Context, buckets []BucketInfo, objAPI ObjectLayer) error {
// Make sure only one node running resync on the cluster.
locker := objAPI.NewNSLock(minioMetaBucket, "replication/resync.lock")
lkctx, err := locker.GetLock(ctx, replicationResyncLockTimeout)
if err != nil {
return err
}
ctx = lkctx.Context()
defer lkctx.Cancel()
// No unlock for "leader" lock.
ctx, cancel := globalLeaderLock.GetLock(ctx)
defer cancel()
for index := range buckets {
meta, err := loadBucketResyncMetadata(ctx, buckets[index].Name, objAPI)
if err != nil {