From 13a2dc84853c97d6fa06e51cd6856d30d1f40e99 Mon Sep 17 00:00:00 2001 From: Poorna Date: Tue, 5 Sep 2023 20:22:39 -0700 Subject: [PATCH] replication resync: avoid blocking on results channel. (#17981) continues fix in #17775 --- cmd/bucket-replication.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index 52b24ca11..a1bb0b7b9 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -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 }