mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Fix XAUTOCLAIM response to return the next available id as the cursor (#8725)
This command used to return the last scanned entry id as the cursor, instead of the next one to be scanned. so in the next call, the user could / should have sent `(cursor` and not just `cursor` if he wanted to avoid scanning the same record twice. Scanning the record twice would look odd if someone is checking what exactly was scanned, but it also has a side effect of incrementing the delivery count twice.
This commit is contained in:
parent
370ab4c4db
commit
44d8b039e8
@ -3151,6 +3151,9 @@ void xautoclaimCommand(client *c) {
|
|||||||
server.dirty++;
|
server.dirty++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We need to return the next entry as a cursor for the next XAUTOCLAIM call */
|
||||||
|
raxNext(&ri);
|
||||||
|
|
||||||
streamID endid;
|
streamID endid;
|
||||||
if (raxEOF(&ri)) {
|
if (raxEOF(&ri)) {
|
||||||
endid.ms = endid.seq = 0;
|
endid.ms = endid.seq = 0;
|
||||||
|
@ -373,7 +373,7 @@ start_server {
|
|||||||
after 200
|
after 200
|
||||||
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 - COUNT 1]
|
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 - COUNT 1]
|
||||||
assert_equal [llength $reply] 2
|
assert_equal [llength $reply] 2
|
||||||
assert_equal [lindex $reply 0] $id1
|
assert_equal [lindex $reply 0] "0-0"
|
||||||
assert_equal [llength [lindex $reply 1]] 1
|
assert_equal [llength [lindex $reply 1]] 1
|
||||||
assert_equal [llength [lindex $reply 1 0]] 2
|
assert_equal [llength [lindex $reply 1 0]] 2
|
||||||
assert_equal [llength [lindex $reply 1 0 1]] 2
|
assert_equal [llength [lindex $reply 1 0 1]] 2
|
||||||
@ -392,7 +392,7 @@ start_server {
|
|||||||
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 - COUNT 2]
|
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 - COUNT 2]
|
||||||
# id1 is self-claimed here but not id2 ('count' was set to 2)
|
# id1 is self-claimed here but not id2 ('count' was set to 2)
|
||||||
assert_equal [llength $reply] 2
|
assert_equal [llength $reply] 2
|
||||||
assert_equal [lindex $reply 0] $id2
|
assert_equal [lindex $reply 0] $id3
|
||||||
assert_equal [llength [lindex $reply 1]] 2
|
assert_equal [llength [lindex $reply 1]] 2
|
||||||
assert_equal [llength [lindex $reply 1 0]] 2
|
assert_equal [llength [lindex $reply 1 0]] 2
|
||||||
assert_equal [llength [lindex $reply 1 0 1]] 2
|
assert_equal [llength [lindex $reply 1 0 1]] 2
|
||||||
@ -438,22 +438,22 @@ start_server {
|
|||||||
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 - COUNT 2]
|
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 - COUNT 2]
|
||||||
assert_equal [llength $reply] 2
|
assert_equal [llength $reply] 2
|
||||||
set cursor [lindex $reply 0]
|
set cursor [lindex $reply 0]
|
||||||
assert_equal $cursor $id2
|
assert_equal $cursor $id3
|
||||||
assert_equal [llength [lindex $reply 1]] 2
|
assert_equal [llength [lindex $reply 1]] 2
|
||||||
assert_equal [llength [lindex $reply 1 0 1]] 2
|
assert_equal [llength [lindex $reply 1 0 1]] 2
|
||||||
assert_equal [lindex $reply 1 0 1] {a 1}
|
assert_equal [lindex $reply 1 0 1] {a 1}
|
||||||
|
|
||||||
# Claim 2 more entries
|
# Claim 2 more entries
|
||||||
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 ($cursor COUNT 2]
|
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 $cursor COUNT 2]
|
||||||
assert_equal [llength $reply] 2
|
assert_equal [llength $reply] 2
|
||||||
set cursor [lindex $reply 0]
|
set cursor [lindex $reply 0]
|
||||||
assert_equal $cursor $id4
|
assert_equal $cursor $id5
|
||||||
assert_equal [llength [lindex $reply 1]] 2
|
assert_equal [llength [lindex $reply 1]] 2
|
||||||
assert_equal [llength [lindex $reply 1 0 1]] 2
|
assert_equal [llength [lindex $reply 1 0 1]] 2
|
||||||
assert_equal [lindex $reply 1 0 1] {c 3}
|
assert_equal [lindex $reply 1 0 1] {c 3}
|
||||||
|
|
||||||
# Claim last entry
|
# Claim last entry
|
||||||
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 ($cursor COUNT 2]
|
set reply [r XAUTOCLAIM mystream mygroup consumer2 10 $cursor COUNT 1]
|
||||||
assert_equal [llength $reply] 2
|
assert_equal [llength $reply] 2
|
||||||
set cursor [lindex $reply 0]
|
set cursor [lindex $reply 0]
|
||||||
assert_equal $cursor {0-0}
|
assert_equal $cursor {0-0}
|
||||||
|
Loading…
Reference in New Issue
Block a user