redis-namespace icon indicating copy to clipboard operation
redis-namespace copied to clipboard

Deprecation warning: Pipelining commands on a Redis instance is deprecated and will be removed in Redis 5.0.0

Open matthewhively opened this issue 3 years ago • 16 comments

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.

matthewhively avatar Mar 09 '22 20:03 matthewhively

Looks like this belongs to the resque gem: https://github.com/resque/resque/blob/master/lib/resque/data_store.rb#L103

danlo avatar Mar 13 '22 00:03 danlo

The warning originates here:

https://github.com/redis/redis-rb/blob/master/lib/redis/pipeline.rb#L56

danlo avatar Mar 13 '22 01:03 danlo

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

danlo avatar Mar 13 '22 01:03 danlo

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.

ericboehs avatar Mar 31 '22 02:03 ericboehs

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

Screenshot 2022-04-22 at 11 53 25

mihael avatar Apr 22 '22 09:04 mihael

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

virgoproz avatar May 04 '22 21:05 virgoproz

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.

mishina2228 avatar Jun 25 '22 00:06 mishina2228

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.

kyrylo avatar Aug 09 '22 11:08 kyrylo

Would be great to push this fix out. Appreciate the efforts here!

nvolker avatar Aug 11 '22 12:08 nvolker

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'}

kyrylo avatar Aug 15 '22 08:08 kyrylo

Should be fixed by Resque 2.3.0 Not quite out yet.

matthewhively avatar Aug 15 '22 17:08 matthewhively

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

matthewhively avatar Aug 22 '22 21:08 matthewhively

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)

matthewhively avatar Aug 22 '22 21:08 matthewhively

Maybe adding the config at the file /config/initializers/redis.rb can ignore the warning, just silence, not fix it.

Redis.silence_deprecations = true

william-eth avatar Aug 23 '22 10:08 william-eth

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

oscaredel avatar Aug 24 '22 09:08 oscaredel

@william-eth - That worked for me for the time being to silence the depreciation (like others said it was flooding my console)

gregblass avatar Aug 25 '22 21:08 gregblass