-
Notifications
You must be signed in to change notification settings - Fork 16
REP-5329 Fix retry on document reads. #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,31 +25,40 @@ func (verifier *Verifier) FetchAndCompareDocuments( | |
| types.ByteCount, | ||
| error, | ||
| ) { | ||
| srcChannel, dstChannel, readSrcCallback, readDstCallback := verifier.getFetcherChannelsAndCallbacks(task) | ||
| var srcChannel, dstChannel <-chan bson.Raw | ||
| var readSrcCallback, readDstCallback func(context.Context, *retry.FuncInfo) error | ||
|
|
||
| results := []VerificationResult{} | ||
| var docCount types.DocumentCount | ||
| var byteCount types.ByteCount | ||
|
|
||
| retryer := retry.New(retry.DefaultDurationLimit) | ||
|
|
||
| err := retryer.Run( | ||
| givenCtx, | ||
| verifier.logger, | ||
| readSrcCallback, | ||
| readDstCallback, | ||
| func(ctx context.Context, _ *retry.FuncInfo) error { | ||
| var err error | ||
| results, docCount, byteCount, err = verifier.compareDocsFromChannels( | ||
| ctx, | ||
| task, | ||
| srcChannel, | ||
| dstChannel, | ||
| ) | ||
| err := retryer. | ||
| WithBefore(func() { | ||
| srcChannel, dstChannel, readSrcCallback, readDstCallback = verifier.getFetcherChannelsAndCallbacks(task) | ||
| }). | ||
|
Comment on lines
+38
to
+40
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to understand why do we need before func. Is it the same as calling the function at the start of the retried function except that the error from it won't be retried?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trick is that there are multiple retried funcs. Having a “before” func guarantees execution of one piece before all the others … which is crucial here because the callbacks & channels have to get recreated every time. I’ll clarify this in docs. |
||
| Run( | ||
| givenCtx, | ||
| verifier.logger, | ||
| func(ctx context.Context, fi *retry.FuncInfo) error { | ||
| return readSrcCallback(ctx, fi) | ||
| }, | ||
| func(ctx context.Context, fi *retry.FuncInfo) error { | ||
| return readDstCallback(ctx, fi) | ||
| }, | ||
| func(ctx context.Context, _ *retry.FuncInfo) error { | ||
| var err error | ||
| results, docCount, byteCount, err = verifier.compareDocsFromChannels( | ||
| ctx, | ||
| task, | ||
| srcChannel, | ||
| dstChannel, | ||
| ) | ||
|
|
||
| return err | ||
| }, | ||
| ) | ||
| return err | ||
| }, | ||
| ) | ||
|
|
||
| return results, docCount, byteCount, err | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we check curFunc to be non-nil both twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 2nd check is probably redundant. I was just trying to suss out why I was seeing segfaults, and I figured I might as well leave the panics in.