-
Notifications
You must be signed in to change notification settings - Fork 22
Wait forever for fatal errors #155
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 |
|---|---|---|
|
|
@@ -35,19 +35,30 @@ func getFunctionName(fn interface{}) string { | |
| return runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name() | ||
| } | ||
|
|
||
| // give either retryInterval or backoff | ||
| // RetryFunc give either retryInterval or backoff | ||
| // gets fn func(int) (bool, error, int) as parameter | ||
| // which returns: | ||
| // bool - whether should be retried | ||
| // error - whether error happened | ||
| // int - increments retries (allows manage retries count from inside of this function) | ||
| func RetryFunc(ctx context.Context, | ||
| loggerInstance logger.Logger, | ||
| attempts int, | ||
| retryInterval *time.Duration, | ||
| backoff *Backoff, | ||
| fn func(int) (bool, error)) error { | ||
| fn func(int) (bool, error, int)) error { | ||
|
|
||
| var err error | ||
| var retry bool | ||
| var addAttempts int | ||
|
|
||
| for attempt := 1; attempt <= attempts; attempt++ { | ||
| retry, err = fn(attempt) | ||
| var attempt = 0 | ||
| for attempt <= attempts { | ||
|
|
||
| attempt++ | ||
| // some errors might require more attempts than expected, so allow incrementing attempts from outside | ||
| retry, err, addAttempts = fn(attempt) | ||
| attempts += addAttempts | ||
|
|
||
| // if there's no need to retry - we're done | ||
| if !retry { | ||
|
|
@@ -178,9 +189,20 @@ func EngineErrorIsNonFatal(err error) bool { | |
| "timeout", | ||
| "refused", | ||
| } | ||
| return errorMatches(err, nonFatalEngineErrorsPartialMatch) | ||
| } | ||
|
|
||
| func EngineErrorIsFatal(err error) bool { | ||
| var fatalEngineErrorsPartialMatch = []string{ | ||
| "lookup v3io-webapi: i/o timeout", | ||
| } | ||
| return errorMatches(err, fatalEngineErrorsPartialMatch) | ||
| } | ||
|
|
||
| func errorMatches(err error, substrings []string) bool { | ||
|
Comment on lines
195
to
202
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. newline |
||
| if err != nil && len(err.Error()) > 0 { | ||
| for _, nonFatalError := range nonFatalEngineErrorsPartialMatch { | ||
| if strings.Contains(err.Error(), nonFatalError) || strings.Contains(errors.Cause(err).Error(), nonFatalError) { | ||
| for _, substring := range substrings { | ||
| if strings.Contains(err.Error(), substring) || strings.Contains(errors.Cause(err).Error(), substring) { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -126,31 +126,47 @@ func (c *claim) fetchRecordBatches(stopChannel chan struct{}, fetchInterval time | |||||||||||||||||||||||
| c.logger, | ||||||||||||||||||||||||
| c.getShardLocationAttempts, | ||||||||||||||||||||||||
| nil, | ||||||||||||||||||||||||
| &c.getShardLocationBackoff, func(attempt int) (bool, error) { | ||||||||||||||||||||||||
| &c.getShardLocationBackoff, | ||||||||||||||||||||||||
| func(attempt int) (bool, error, int) { | ||||||||||||||||||||||||
| c.currentShardLocation, err = c.getCurrentShardLocation(c.shardID) | ||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||
| if common.EngineErrorIsNonFatal(err) { | ||||||||||||||||||||||||
| return true, errors.Wrap(err, "Failed to get shard location due to a network error") | ||||||||||||||||||||||||
| return true, errors.Wrap(err, "Failed to get shard location due to a network error"), 0 | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // if the error is fatal and requires external resolution, | ||||||||||||||||||||||||
| // we don't want to fail; instead, we will inform the user via a log | ||||||||||||||||||||||||
| if common.EngineErrorIsFatal(err) { | ||||||||||||||||||||||||
| // although RetryFunc already logs the error, it logs it as a warning | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| loggerInstance.WarnWithCtx(ctx, | |
| "Context error detected during retries", | |
| "ctxErr", ctx.Err(), | |
| "previousErr", err, | |
| "function", getFunctionName(fn), | |
| "attempt", attempt) | |
| // return the error if one was provided | |
| if err != nil { | |
| return 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.
This warning is for a ctx.Error, like if an external error happened.
In your case you check the error returned from getCurrentShardLocation, which isn't handled by the retry func.
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.
@TomerShor right 🤦
i'll remove comment
Uh oh!
There was an error while loading. Please reload this page.