Skip to content

Retry on timeout or temporary errors - #2312

Merged
ttaylorr merged 4 commits into
git-lfs:masterfrom
jakub-m:fix-retry-on-url-errors
Jun 14, 2017
Merged

ttaylorr merged 4 commits into
git-lfs:masterfrom
jakub-m:fix-retry-on-url-errors

Conversation

@jakub-m

@jakub-m jakub-m commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

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:9000 and nc -v -l 9000 was listening locally.

Without the fix git-lfs client aborted instantly, with the fix it retried.

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 ttaylorr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tq/transfer_queue.go Outdated
// 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about just putting that code in errors.IsRetriableError so that all callers recognize *url.Error?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I dig that a bunch. @jakub-m what do you think?

@jakub-m jakub-m Jun 10, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ttaylorr Sure will rewrite it and add the tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

@jakub-m jakub-m Jun 14, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests, moved the logic to errors.isRetriableError().

@ttaylorr ttaylorr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those tests look phenomenal! Thanks so much for taking the time to address mine and @technoweenie's suggestions.

@ttaylorr
ttaylorr merged commit 37bca6c into git-lfs:master Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants