Skip to content

Commit afece36

Browse files
committed
Fix XAUTOCLAIM when entry is deleted
1 parent 245edf6 commit afece36

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/redis/commands.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ module Commands
119119
HashifyStreamAutoclaim = lambda { |reply|
120120
{
121121
'next' => reply[0],
122-
'entries' => reply[1].map { |entry| [entry[0], entry[1].each_slice(2).to_h] }
122+
'entries' => reply[1].compact.map do |entry, values|
123+
[entry, values.each_slice(2)&.to_h]
124+
end
123125
}
124126
}
125127

test/lint/streams.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,22 @@ def test_xautoclaim_with_larger_interval
712712
assert_equal [], actual['entries']
713713
end
714714

715+
def test_xautoclaim_with_deleted_entry
716+
omit_version(MIN_REDIS_VERSION_XAUTOCLAIM)
717+
718+
redis.xadd('s1', { f: 'v1' }, id: '0-1')
719+
redis.xgroup(:create, 's1', 'g1', '$')
720+
redis.xadd('s1', { f: 'v2' }, id: '0-2')
721+
redis.xreadgroup('g1', 'c1', 's1', '>')
722+
redis.xdel('s1', '0-2')
723+
sleep 0.01
724+
725+
actual = redis.xautoclaim('s1', 'g1', 'c2', 0, '0-0')
726+
727+
assert_equal '0-0', actual['next']
728+
assert_equal [], actual['entries']
729+
end
730+
715731
def test_xpending
716732
redis.xadd('s1', { f: 'v1' }, id: '0-1')
717733
redis.xgroup(:create, 's1', 'g1', '$')

0 commit comments

Comments
 (0)