Skip to content
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

Non-idempotent read timeouts are retried #897

Open
pkoenig10 opened this issue Nov 30, 2018 · 4 comments
Open

Non-idempotent read timeouts are retried #897

pkoenig10 opened this issue Nov 30, 2018 · 4 comments

Comments

@pkoenig10
Copy link
Member

pkoenig10 commented Nov 30, 2018

What happened?

A non-idempotent HTTP request was retried when the original request failed due to a read timeout.

The retried request succeeded. However the original request also eventually succeeded. This left the service in an incorrect state because an action that should have only been attempted once was performed twice.

What did you want to happen?

Requests should only be retried if either:

  • The request is idempotent, according to the HTTP spec
  • The request did not send any data to the server (ex. a connect timeout)

Differentiating between connect timeouts and read timeouts is currently an open issue in OkHttp:
square/okhttp#3318

Until that issue is resolved, we should bias towards the more limiting, but safe behavior of not retrying non-idempotent requests.

@pkoenig10 pkoenig10 changed the title Non-idempotent timeouts are retried Non-idempotent read timeouts are retried Nov 30, 2018
@zakmagnus
Copy link

I believe there are also other times when any request can be safely retried. The important property is that the remote service did not and will not do any work for that request. For example, if the remote service responds with a 503, it certainly received the request, but also certainly did no work for it (assuming it uses the response code correctly), so it's safe to retry that.

@Hazer
Copy link

Hazer commented Mar 30, 2019

square/okhttp#3318 is closed and as @swankjesse pointed out, there may be issues with proxies, QUIC and other things that are hard to be sure

@zakmagnus
Copy link

If you can't tell whether or not the server has received the request, then the correct thing to do is to not retry. Retrying a non-idempotent request is an optimization for the special case that you do know for a fact it's safe to do. If you can't tell you're in the special case, don't try to optimize.

@stale
Copy link

stale bot commented Sep 23, 2019

This issue has been automatically marked as stale because it has not been touched in the last 60 days. Please comment if you'd like to keep it open, otherwise it'll be closed in 7 days time.

@stale stale bot added the stale label Sep 23, 2019
@iamdanfox iamdanfox removed the stale label Sep 23, 2019
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

No branches or pull requests

4 participants