Use the same lock for the scanner and site replication healing (#15985)

This commit is contained in:
Anis Elleuch
2022-11-08 17:55:55 +01:00
committed by GitHub
parent 52769e1e71
commit 3b1a9b9fdf
5 changed files with 97 additions and 34 deletions

View File

@@ -3577,12 +3577,6 @@ func (c *SiteReplicationSys) PeerEditReq(ctx context.Context, arg madmin.PeerInf
const siteHealTimeInterval = 10 * time.Second
var siteReplicationHealLockTimeout = newDynamicTimeoutWithOpts(dynamicTimeoutOpts{
timeout: 30 * time.Second,
minimum: 10 * time.Second,
retryInterval: time.Second,
})
func (c *SiteReplicationSys) startHealRoutine(ctx context.Context, objAPI ObjectLayer) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
// Run the site replication healing in a loop
@@ -3598,15 +3592,8 @@ func (c *SiteReplicationSys) startHealRoutine(ctx context.Context, objAPI Object
}
func (c *SiteReplicationSys) healRoutine(ctx context.Context, objAPI ObjectLayer) {
// Make sure only one node running site replication on the cluster.
locker := objAPI.NewNSLock(minioMetaBucket, "site-replication/heal.lock")
lkctx, err := locker.GetLock(ctx, siteReplicationHealLockTimeout)
if err != nil {
return
}
ctx = lkctx.Context()
defer lkctx.Cancel()
// No unlock for "leader" lock.
ctx, cancel := globalLeaderLock.GetLock(ctx)
defer cancel()
healTimer := time.NewTimer(siteHealTimeInterval)
defer healTimer.Stop()