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

429 responses w/o retry_after_ms cause exception #193

Open
ulope opened this issue Apr 15, 2018 · 4 comments
Open

429 responses w/o retry_after_ms cause exception #193

ulope opened this issue Apr 15, 2018 · 4 comments

Comments

@ulope
Copy link
Contributor

ulope commented Apr 15, 2018

Sometimes (no idea how this is triggered) synapse sends responses with a 429 status code without the retry_after_ms field. In those cases, the python client crashes with a KeyError since

sleep(response.json()['retry_after_ms'] / 1000)
unconditionally expects retry_after_ms to be available on 429 responses.

A relatively simple solution would be to have our own internal exponential backoff counter that gets reset every time a request succeeds or an explicit retry_after_ms value is received.

What do you think?

@ulope
Copy link
Contributor Author

ulope commented Apr 15, 2018

Looking a bit more into this it seems that in the case I'm seeing the retry_after_ms field is actually nested inside the error value:

{
  "errcode": "M_UNKNOWN", 
  "error": "{\"errcode\":\"M_LIMIT_EXCEEDED\",\"error\":\"Too Many Requests\",\"retry_after_ms\":650}"
}

ulope added a commit to ulope/raiden that referenced this issue Apr 15, 2018
@non-Jedi
Copy link
Collaborator

non-Jedi commented Apr 17, 2018

Without doing any digging, this sounds like a synapse bug. @ulope, any
particular endpoint causing this problem? Or is it completely random?

If anyone starts a PR to try to address this, please don't add any blocking code
(such as a exponential backoff counter) directly to MatrixHttpApi. We want
those methods to return as soon as possible, and I'm not really happy with even
the 429-handling logic that currently lives there; I just haven't come up with a
better place to put it yet.

@ulope
Copy link
Contributor Author

ulope commented Apr 19, 2018

@non-Jedi I can't be sure (I'll have to re-run the test that triggered this when I get a chance) but IIRC it was either during login / registration or joining rooms.

@non-Jedi
Copy link
Collaborator

To be clear, I've merged a PR (in release v0.2.0) that works around this issue, but I'm leaving it open to track the upstream problem.

ulope added a commit to ulope/raiden that referenced this issue Apr 23, 2018
ulope added a commit to ulope/raiden that referenced this issue May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants