Retry-After retourne avec 0 secondes

When we retry after a 429, we get another 429.

I suspect a round-down issue.

In our scenario:

  • we do requests, and eventually get a 429 Too Many Request with Retry-After: 19
  • we wait 19 seconds, then try again:
    —> We get a 429 again, with Retry-After: 0

Now, can it be the actual values were 19.4 and 0.4 for example and they were rounded down for the Retry-After in the headers?

4 « J'aime »

Probably, should be an easy fix. Another starter task @erlend_sh?

2 « J'aime »

I’m not entirely sure where this is happening, but I suspect it has to do with use of Lua’s tonumber() in rate_limiter.rb—quoth Redis’ EVAL documentation:

Lua has a single numerical type, Lua numbers. There is no distinction between integers and floats. So we always convert Lua numbers into integer replies, removing the decimal part of the number if any.

4 « J'aime »

Je m’occupe de ce bug et je vais soumettre une pull-request demain.

1 « J'aime »

Il s’est avéré que ce n’était pas un problème d’arrondi dans le script Lua. Le script Lua reçoit déjà des valeurs arrondies.

De plus, ce n’est pas un problème d’arrondi du tout. Des secondes non arrondies peuvent être utilisées, et il serait tout de même possible de recevoir une réponse 429 avec Retry-After: 0.

Voici la correction du problème principal :

Et voici la correction d’un problème supplémentaire qui peut occasionnellement causer la même erreur :

3 « J'aime »