From cbdc0095ac7cb18422aaac807de9c798ec9f1d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Thu, 29 Feb 2024 17:42:45 +0000 Subject: [PATCH] errgroup: return context.Canceled instead of using another context errgroup seems to prefer the error raised by one of its goroutines rather than the calling context's cancelation for Wait's return value, return context.Canceled to set Wait result & cancel pull --- flow/activities/flowable.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/flow/activities/flowable.go b/flow/activities/flowable.go index 9767ac8108..9fa859b5b4 100644 --- a/flow/activities/flowable.go +++ b/flow/activities/flowable.go @@ -640,8 +640,7 @@ func (a *FlowableActivity) replicateQRepPartition(ctx context.Context, var rowsSynced int bufferSize := shared.FetchAndChannelSize if config.SourcePeer.Type == protos.DBType_POSTGRES { - taskCtx, taskCancel := context.WithCancel(ctx) - errGroup, errCtx := errgroup.WithContext(taskCtx) + errGroup, errCtx := errgroup.WithContext(ctx) stream := model.NewQRecordStream(bufferSize) errGroup.Go(func() error { pgConn := srcConn.(*connpostgres.PostgresConnector) @@ -666,8 +665,7 @@ func (a *FlowableActivity) replicateQRepPartition(ctx context.Context, a.Alerter.LogFlowError(ctx, config.FlowJobName, err) return fmt.Errorf("failed to sync records: %w", err) } - taskCancel() - return nil + return context.Canceled }) err = errGroup.Wait()