Only increment delivery count if JUSTID option is omitted

This commit is contained in:
Steve Webster 2019-03-12 20:27:53 +00:00
parent f1e7df4b7c
commit dfcb227b50
2 changed files with 18 additions and 3 deletions

View File

@ -2279,10 +2279,11 @@ void xclaimCommand(client *c) {
/* Update the consumer and idle time. */ /* Update the consumer and idle time. */
nack->consumer = consumer; nack->consumer = consumer;
nack->delivery_time = deliverytime; nack->delivery_time = deliverytime;
/* Set the delivery attempts counter if given, otherwise autoincrement */ /* Set the delivery attempts counter if given, otherwise
* autoincrement unless JUSTID option provided */
if (retrycount >= 0) { if (retrycount >= 0) {
nack->delivery_count = retrycount; nack->delivery_count = retrycount;
} else { } else if (!justid) {
nack->delivery_count++; nack->delivery_count++;
} }
/* Add the entry in the new consumer local PEL. */ /* Add the entry in the new consumer local PEL. */

View File

@ -195,7 +195,7 @@ start_server {
assert_equal "" [lindex $reply 0] assert_equal "" [lindex $reply 0]
} }
test {XCLAIM increments delivery count} { test {XCLAIM without JUSTID increments delivery count} {
# Add 3 items into the stream, and create a consumer group # Add 3 items into the stream, and create a consumer group
r del mystream r del mystream
set id1 [r XADD mystream * a 1] set id1 [r XADD mystream * a 1]
@ -222,6 +222,20 @@ start_server {
] ]
assert {[llength [lindex $reply 0]] == 4} assert {[llength [lindex $reply 0]] == 4}
assert {[lindex $reply 0 3] == 2} assert {[lindex $reply 0 3] == 2}
# Client 3 then claims pending item 1 from the PEL of client 2 using JUSTID
r debug sleep 0.2
set reply [
r XCLAIM mystream mygroup client3 10 $id1 JUSTID
]
assert {[llength $reply] == 1}
assert {[lindex $reply 0] eq $id1}
set reply [
r XPENDING mystream mygroup - + 10
]
assert {[llength [lindex $reply 0]] == 4}
assert {[lindex $reply 0 3] == 2}
} }
start_server {} { start_server {} {