Retry-After restituisce 0 secondi

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 Mi Piace

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

2 Mi Piace

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 Mi Piace

Mi sto occupando di questo bug e invierò una pull request domani.

1 Mi Piace

È risultato che non si trattava di un problema di arrotondamento nello script Lua. Lo script Lua riceve già valori arrotondati.

Inoltre, non si tratta affatto di un problema di arrotondamento. Potrebbero essere utilizzati secondi non arrotondati e, in ogni caso, sarebbe possibile ricevere una risposta 429 con Retry-After: 0.

Ecco la correzione per il problema principale:

Ecco la correzione per un problema aggiuntivo che occasionalmente può causare lo stesso errore:

3 Mi Piace