fix: potential data conflicts save site-resync metadata (#16926)

This commit is contained in:
jiuker 2023-03-31 11:59:45 +08:00 committed by GitHub
parent d703daa480
commit a7b7860e0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -170,6 +170,7 @@ func (sm *siteResyncMetrics) save(ctx context.Context) {
case <-sTimer.C:
if globalSiteReplicationSys.isEnabled() {
sm.Lock()
wg := sync.WaitGroup{}
for dID, rs := range sm.peerResyncMap {
st, ok := sm.resyncStatus[rs.resyncID]
if ok {
@ -179,9 +180,14 @@ func (sm *siteResyncMetrics) save(ctx context.Context) {
}
rs.LastSaved = UTCNow()
sm.peerResyncMap[dID] = rs
go saveSiteResyncMetadata(ctx, st, newObjectLayerFn())
wg.Add(1)
go func() {
defer wg.Done()
saveSiteResyncMetadata(ctx, st, newObjectLayerFn())
}()
}
}
wg.Wait()
sm.Unlock()
}
sTimer.Reset(siteResyncSaveInterval)