Open m-shimojo opened 1 year ago
This looks like yet another issue caused by https://github.com/resque/resque-scheduler/pull/767, because it tries to wrap all the enqueues done by resque-scheduler in a MULTI
/EXEC
transaction. Circa Redis 4.x, this means the Redis commands in your before_enqueue
hook are being stashed as a Redis::Future
and only fired when the MULTI
block gets sent. (Circa Redis 5.x, the commands happen to get sent outside of the ongoing transaction, but I believe this to be a bug with what the transaction is trying to accomplish.)
So effectively, this is what's happening:
[1] pry(main)> require 'redis'
=> true
[2] pry(main)> Redis::VERSION
=> "4.8.1"
[3] pry(main)> r = Redis.new
=> #<Redis client v4.8.1 for redis://127.0.0.1:6379/0>
[4] pry(main)> r.multi { r.llen('anything').to_i }
Pipelining commands on a Redis instance is deprecated and will be removed in Redis 5.0.0.
redis.multi do
redis.get("key")
end
should be replaced by
redis.multi do |pipeline|
pipeline.get("key")
end
(called from (pry):4:in `__pry__'}
NoMethodError: undefined method `to_i' for <Redis::Future [:llen, "anything"]>:Redis::Future
from (pry):4:in `block in __pry__'
See also:
We have updated resque-scheduler to 4.9.0 in our project and we are getting an error on
before_enqueue
while running a delayed job. The same error is occurring in 4.10.0 as well. The error occurs when using redis-rb 4.x and not with 5.x. However, we have not been able to update to 5.x due to dependency issues, so is there any way to resolve this error while still using 4.x?I guess it has something to do with #773.
Expected behavior
No errors.
Actual behavior
NoMethodError is raised.
Full log:
Steps to reproduce the problem
Create a job that run methods to access Redis such as
Resque.size
andResque.peek
inbefore_enqueue
.Repository for reproduction: https://github.com/m-shimojo/repro-resque-scheduler-hooks-issue