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

Claiming trimmed messages from a stream leads to an error

Open flash-gordon opened this issue 5 years ago • 2 comments

What happens:

  1. Consumer reads a message then fails.
  2. The message is added to the list of pending.
  3. After a while, the stream is trimmed and the message is removed yet it's still on the list of pending.
  4. Recover process tries to claim the message, redis-rb throws an error;
redis.xclaim(stream, consumer_group, consumer, 0, [pending_id])
       undefined method `each_slice' for nil:NilClass
     # redis-4.2.1/lib/redis.rb:3428:in `block (2 levels) in <class:Redis>'
     # redis-4.2.1/lib/redis.rb:3427:in `map'
     # redis-4.2.1/lib/redis.rb:3427:in `block in <class:Redis>'
     # redis-4.2.1/lib/redis/client.rb:130:in `call'
     # redis-4.2.1/lib/redis.rb:3222:in `block in xclaim'
     # redis-4.2.1/lib/redis.rb:69:in `block in synchronize'
     # /Users/gordon/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
     # /Users/gordon/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
     # redis-4.2.1/lib/redis.rb:69:in `synchronize'
     # redis-4.2.1/lib/redis.rb:3222:in `xclaim'

I think trimmed messages should result in nil.

flash-gordon avatar Aug 20 '20 12:08 flash-gordon

There's justid option in xclaim that will avoid hashifying fetched records. Still, the current error is confusing, it'd be better to have MessageDeletedError or something like that.

flash-gordon avatar Aug 20 '20 13:08 flash-gordon

It seems like that the error is related to #929.

supercaracal avatar Aug 22 '20 04:08 supercaracal