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

ERR value is not an integer or out of rang #39

Closed
morgoth opened this issue Mar 22, 2022 · 2 comments
Closed

ERR value is not an integer or out of rang #39

morgoth opened this issue Mar 22, 2022 · 2 comments

Comments

@morgoth
Copy link

morgoth commented Mar 22, 2022

When trying the prorate gem, I'm running into redis error:

require "prorate"
require "async"

Async do |task|
  11.times do |i|
    task.async do
      t = Prorate::Throttle.new(
          redis: $redis,
          logger: Rails.logger,
          name: "throttler",
          limit: 10,
          period: 1,
          block_for: 0.5
      )
      t << "counter"
      t.throttle!
    end
  end
end.wait
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
Applying throttle counter throttler
    8m    error: Async::Task [oid=0xaca8] [ec=0xacbc] [pid=742358] [2022-03-22 15:57:27 +0100]
               |   Redis::CommandError: ERR Error running script (call to f_18f5304b307c1151f10cef5f9757e8cf742c37b7): @user_script:51: ERR value is not an integer or out of range
               |   → /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/redis-4.6.0/lib/redis/client.rb:162 in `call'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/redis-4.6.0/lib/redis.rb:263 in `block in send_command'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/redis-4.6.0/lib/redis.rb:262 in `synchronize'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/redis-4.6.0/lib/redis.rb:262 in `send_command'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/redis-4.6.0/lib/redis/commands/scripting.rb:110 in `_eval'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/redis-4.6.0/lib/redis/commands/scripting.rb:97 in `evalsha'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/prorate-0.7.1/lib/prorate/throttle.rb:146 in `block in run_lua_throttler'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/prorate-0.7.1/lib/prorate/null_pool.rb:4 in `with'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/prorate-0.7.1/lib/prorate/throttle.rb:144 in `run_lua_throttler'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/prorate-0.7.1/lib/prorate/throttle.rb:91 in `throttle!'
               |     (irb):211 in `block (3 levels) in <top (required)>'
               |     /home/wojtek/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/async-2.0.1/lib/async/task.rb:258 in `block in schedule'

so it throws out when it should throttle (on the 11 call).
Do you know what could be the cause?

@lorenzograndi4
Copy link
Contributor

Hey @morgoth 👋

I suspect the :block_for value has to be an integer, not a float. Could you try?

@morgoth
Copy link
Author

morgoth commented Mar 24, 2022

yes, this is it. So it is not possible to block for less time than 1s?

@morgoth morgoth closed this as completed Mar 24, 2022
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

2 participants