redis-namespace
redis-namespace copied to clipboard
Deprecation warning: Pipelining commands on a Redis instance is deprecated and will be removed in Redis 5.0.0
Raised multiple times when performing Resque.enqueue by lib/redis/namespace.rb line 530 in version 1.8.2 of redis-namespace
I'm not sure whether this is an issue with the redis-namespace, or with the way that Resque itself is passing commands to the namespace.
Looks like this belongs to the resque gem: https://github.com/resque/resque/blob/master/lib/resque/data_store.rb#L103
The warning originates here:
https://github.com/redis/redis-rb/blob/master/lib/redis/pipeline.rb#L56
I looked though the redis-namespace code and found the following which may be of interest:
https://github.com/resque/redis-namespace/blob/master/lib/redis/namespace.rb#L529
def namespaced_block(command, &block)
if block.arity == 0
redis.send(command, &block)
else
redis.send(command) do |r|
copy = dup
Reading the redis documentation, I believe that an argument is always meant to always be passed.
https://github.com/redis/redis-rb#pipelining
Thus, block.arity == 0 should never happen?
-daniel
You're right, block.arity ==0 should never happen, but it is because whatever is calling your Redis connection is passing a block without an arg. The issue isn't with this gem (afaict), but with your app code.
Unfortunately the deprecation doesn't give a stack trace (even with ActiveSupport::Deprecation.debug = true set). In order to debug this, I edited the gem (bundle open redis-namespace) and threw a puts command, block in the arity == 0 if block (line 530).
This showed me the actual location of the bad code (e.g. calling .multi without an arg).
Removing the arity == 0 check here will just cause errors or push the deprecation to another line.
Am using redis with resque, and here's the problematic code:
https://github.com/resque/resque/blob/master/lib/resque/data_store.rb#L102-L106
Correct, data_store.rb in the current version of the Resque gem needs to be refactored to remove the deprecated use of .pipelined (without args)! Should be a no-brainer
Am using redis with resque, and here's the problematic code:
https://github.com/resque/resque/blob/master/lib/resque/data_store.rb#L102-L106
Now this part has been fixed in resque/resque#1806. https://github.com/resque/resque/blob/ba5a44294ba5f6c4593deb78612f78989445d83e/lib/resque/data_store.rb#L102-L107
New version of resque has not yet been released though.
Can we push a new release, please? This warning is a little bit annoying since, in my case, it's being run almost after every single test that I have.
Would be great to push this fix out. Appreciate the efforts here!
I can see v1.9.0 was pushed on August 13, 2022 but this warning has not been fixed for me.
Pipelining commands on a Redis instance is deprecated and will be removed in Redis 5.0.0.
redis.pipelined do
redis.get("key")
end
should be replaced by
redis.pipelined do |pipeline|
pipeline.get("key")
end
(called from /Users/kyrylosilin/.gem/ruby/2.7.6/gems/redis-namespace-1.9.0/lib/redis/namespace.rb:533:in `namespaced_block'}
Should be fixed by Resque 2.3.0 Not quite out yet.
Looks like not everything is fixed by resque 2.3.0 Still receiving these even after upgrading to Resque 2.3.0 & redis-namespace 1.9.0
I also see this warning raised now too:
Redis#sadd will always return an Integer in Redis 5.0.0. Use Redis#sadd? instead.(called from: ~/.rvm/gems/ruby-2.5.7/gems/redis-namespace-1.9.0/lib/redis/namespace.rb:479:in 'call_with_namespace')
# Dispatch the command to Redis and store the result.
result = @redis.send(command, *args, &block)
Maybe adding the config at the file /config/initializers/redis.rb can ignore the warning, just silence, not fix it.
Redis.silence_deprecations = true
I also see this warning raised now too:
Redis#sadd will always return an Integer in Redis 5.0.0. Use Redis#sadd? instead.(called from: ~/.rvm/gems/ruby-2.5.7/gems/redis-namespace-1.9.0/lib/redis/namespace.rb:479:in 'call_with_namespace')
I've created a PR for this one: https://github.com/resque/redis-namespace/pull/207
@william-eth - That worked for me for the time being to silence the depreciation (like others said it was flooding my console)