Repository navigation
Retry on timeout or temporary errors - #2312
Conversation
git-lfs could fail randomly on "i/o timeout" error. This is especially annoying with very long running transfers. This change recognises Timeout or Temporary errors and retries them.
ttaylorr
left a comment
There was a problem hiding this comment.
Thanks so much for this @jakub-m! I left one comment for your consideration, to be more aligned with the type-cast style we use throughout the majority of LFS.
Do you think it would be worthwhile to add a unit test for this? I don't think forcing a *url.Error via an integration test is necessary, but perhaps a test case of constructing a *url.Error and passing it to the canRetry() function would be legit.
| // canRetry returns whether or not the given error "err" is retriable. | ||
| func (q *TransferQueue) canRetry(err error) bool { | ||
| return errors.IsRetriableError(err) | ||
| switch cause := errors.Cause(err).(type) { |
There was a problem hiding this comment.
Rad ⚡️. I know that both the switch (...).(type) is a legit way to do this, but I think the convention in the majority of LFS looks something like:
func (q *TransferQueue) canRetry(err error) bool {
err = errors.Cause(err)
if cause, ok := err.(*url.Error); ok {
return cause.Temporary() || cause.Timeout()
}
return errors.IsRetriableError(err)
}There was a problem hiding this comment.
What would you think about just putting that code in errors.IsRetriableError so that all callers recognize *url.Error?
There was a problem hiding this comment.
Ah, I dig that a bunch. @jakub-m what do you think?
There was a problem hiding this comment.
@ttaylorr Sure will rewrite it and add the tests.
There was a problem hiding this comment.
@technoweenie Initially I had it in errors.IsRetriableError but then I moved it to canRetry, because it seems that errors.IsRetriableError, together with the other functions types.go, are about type inference, and not about flow control. I don't know the codebase and the conventions there well so I am ok to move it there if you are sure this is the place.
There was a problem hiding this comment.
That's a good point. Though, I don't think the errors package strictly has to be about type inference. The Temporary() and Timeout() methods didn't exist in Go, otherwise we would've used them. I'd prefer to move this to errors.IsRetriableError(), but don't have strong feelings. @ttaylorr any thoughts?
There was a problem hiding this comment.
I'd prefer to move this to
errors.IsRetriableError(), but don't have strong feelings. @ttaylorr any thoughts?
I agree; I think this is most well-suited in errors.IsRetriableError().
There was a problem hiding this comment.
Added tests, moved the logic to errors.isRetriableError().
ttaylorr
left a comment
There was a problem hiding this comment.
Those tests look phenomenal! Thanks so much for taking the time to address mine and @technoweenie's suggestions.
git-lfs could fail randomly on "i/o timeout" error. This is especially
annoying with very long running transfers. This change recognises
Timeout or Temporary errors and retries them.
Tested by doing git lfs smudge on a file in lfs repository, where
lfs.url=http://localhost:9000andnc -v -l 9000was listening locally.Without the fix git-lfs client aborted instantly, with the fix it retried.