-
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
Conversation
tdq45gj
left a comment
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.
LGTM % two questions.
internal/retry/retry.go
Outdated
| } | ||
|
|
||
| eg.Go(func() error { | ||
| if curFunc == nil { |
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.
| WithBefore(func() { | ||
| srcChannel, dstChannel, readSrcCallback, readDstCallback = verifier.getFetcherChannelsAndCallbacks(task) | ||
| }). |
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.
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?
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.
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.
Commit 31cc703 was broken because it didn’t actually recreate the callbacks as needed to redo the reads.
(Unfortunately there’s little good way to test this directly, but mongosync’s CI testing caught it.)
This changeset fixes that by adding a callback to the retryer that runs at the start of each iteration.