Retry-After が 0 秒で返される

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

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

「いいね!」 2

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

このバグの対応を進めており、明日プルリクエストを提出する予定です。

「いいね!」 1

実は、Lua スクリプトの丸め処理に問題があったわけではありません。Lua スクリプトにはすでに丸められた値が渡されています。

さらに、これは丸め処理の問題自体でもありません。丸められていない秒数が使用される場合、Retry-After: 0 で 429 応答が返される可能性は常にあります。

主な問題の修正は以下の通りです:

また、同様のエラーを時折引き起こす可能性のある追加の問題の修正は以下の通りです:

「いいね!」 3