replication resync: avoid blocking on results channel. (#17981)

continues fix in #17775
This commit is contained in:
Poorna 2023-09-05 20:22:39 -07:00 committed by GitHub
parent 1e51424e8a
commit 13a2dc8485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2531,6 +2531,13 @@ func (s *replicationResyncer) resyncBucket(ctx context.Context, objectAPI Object
workers := make([]chan ReplicateObjectInfo, resyncParallelRoutines)
resultCh := make(chan TargetReplicationResyncStatus, 1)
defer close(resultCh)
go func() {
for r := range resultCh {
s.incStats(r, opts)
globalSiteResyncMetrics.updateMetric(r, opts.resyncID)
}
}()
var wg sync.WaitGroup
for i := 0; i < resyncParallelRoutines; i++ {
wg.Add(1)
@ -2635,12 +2642,6 @@ func (s *replicationResyncer) resyncBucket(ctx context.Context, objectAPI Object
for i := 0; i < resyncParallelRoutines; i++ {
close(workers[i])
}
go func() {
for r := range resultCh {
s.incStats(r, opts)
globalSiteResyncMetrics.updateMetric(r, opts.resyncID)
}
}()
wg.Wait()
resyncStatus = ResyncCompleted
}