forked from Silverfish/proton-bridge
fix(GODT-3124): Race condition in sync task waiter
Fix incorrect use of `sync.WaitGroup` use to wait on sync jobs that fail. After calling `WaitGroup.Wait()` it is advised to call `WaitGroup.Add` until the existing counter has reached 0. The code has been updated with a different mechanism that achieves the same behavior which was previously available.
This commit is contained in:
@ -210,12 +210,10 @@ func (t *Handler) run(ctx context.Context,
|
||||
stageContext.metadataFetched = syncStatus.NumSyncedMessages
|
||||
stageContext.totalMessageCount = syncStatus.TotalMessageCount
|
||||
|
||||
defer stageContext.Close()
|
||||
|
||||
t.regulator.Sync(ctx, stageContext)
|
||||
|
||||
// Wait on reply
|
||||
if err := stageContext.wait(ctx); err != nil {
|
||||
if err := stageContext.waitAndClose(ctx); err != nil {
|
||||
return fmt.Errorf("failed sync messages: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user