Skip to content

Commit 5c035cf

Browse files
committed
check for errors
1 parent 313f9e6 commit 5c035cf

File tree

1 file changed

+22
-35
lines changed

1 file changed

+22
-35
lines changed

internal/verifier/compare.go

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"context"
66

7-
"github.com/10gen/migration-verifier/internal/retry"
87
"github.com/10gen/migration-verifier/internal/types"
98
"github.com/pkg/errors"
109
"go.mongodb.org/mongo-driver/bson"
@@ -22,43 +21,31 @@ func (verifier *Verifier) FetchAndCompareDocuments(
2221
types.ByteCount,
2322
error,
2423
) {
25-
var results []VerificationResult
24+
// This function spawns three threads: one to read from the source,
25+
// another to read from the destination, and a third one to receive the
26+
// docs from the other 2 threads and compare them. It’s done this way,
27+
// rather than fetch-everything-then-compare, to minimize memory usage.
28+
errGroup, ctx := errgroup.WithContext(givenCtx)
29+
30+
srcChannel, dstChannel := verifier.getFetcherChannels(ctx, errGroup, task)
31+
32+
results := []VerificationResult{}
2633
var docCount types.DocumentCount
2734
var byteCount types.ByteCount
2835

29-
retryer := retry.New(retry.DefaultDurationLimit)
30-
31-
err := retryer.RunForTransientErrorsOnly(
32-
givenCtx,
33-
verifier.logger,
34-
func(_ *retry.Info) error {
35-
results = []VerificationResult{}
36-
docCount = 0
37-
byteCount = 0
38-
39-
// This function spawns three threads: one to read from the source,
40-
// another to read from the destination, and a third one to receive the
41-
// docs from the other 2 threads and compare them. It’s done this way,
42-
// rather than fetch-everything-then-compare, to minimize memory usage.
43-
errGroup, ctx := errgroup.WithContext(givenCtx)
44-
45-
srcChannel, dstChannel := verifier.getFetcherChannels(ctx, errGroup, task)
46-
47-
errGroup.Go(func() error {
48-
var err error
49-
results, docCount, byteCount, err = verifier.compareDocsFromChannels(
50-
ctx,
51-
task,
52-
srcChannel,
53-
dstChannel,
54-
)
55-
56-
return err
57-
})
58-
59-
return errGroup.Wait()
60-
},
61-
)
36+
errGroup.Go(func() error {
37+
var err error
38+
results, docCount, byteCount, err = verifier.compareDocsFromChannels(
39+
ctx,
40+
task,
41+
srcChannel,
42+
dstChannel,
43+
)
44+
45+
return err
46+
})
47+
48+
err := errGroup.Wait()
6249

6350
return results, docCount, byteCount, err
6451
}

0 commit comments

Comments
 (0)