Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
3e648907
Unverified
Commit
3e648907
authored
Mar 13, 2019
by
Salvatore Sanfilippo
Committed by
GitHub
Mar 13, 2019
Browse files
Merge pull request #5907 from spjwebster/xclaim-increment-delivery-count
Increment delivery counter on XCLAIM unless RETRYCOUNT specified
parents
610aff32
dfcb227b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/t_stream.c
View file @
3e648907
...
@@ -2279,8 +2279,13 @@ void xclaimCommand(client *c) {
...
@@ -2279,8 +2279,13 @@ 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. */
/* Set the delivery attempts counter if given, otherwise
if
(
retrycount
>=
0
)
nack
->
delivery_count
=
retrycount
;
* autoincrement unless JUSTID option provided */
if
(
retrycount
>=
0
)
{
nack
->
delivery_count
=
retrycount
;
}
else
if
(
!
justid
)
{
nack
->
delivery_count
++
;
}
/* Add the entry in the new consumer local PEL. */
/* Add the entry in the new consumer local PEL. */
raxInsert
(
consumer
->
pel
,
buf
,
sizeof
(
buf
),
nack
,
NULL
);
raxInsert
(
consumer
->
pel
,
buf
,
sizeof
(
buf
),
nack
,
NULL
);
/* Send the reply for this entry. */
/* Send the reply for this entry. */
...
...
tests/unit/type/stream-cgroups.tcl
View file @
3e648907
...
@@ -195,6 +195,49 @@ start_server {
...
@@ -195,6 +195,49 @@ start_server {
assert_equal
""
[
lindex $reply 0
]
assert_equal
""
[
lindex $reply 0
]
}
}
test
{
XCLAIM without JUSTID increments delivery count
}
{
# Add 3 items into the stream, and create a consumer group
r del mystream
set id1
[
r XADD mystream * a 1
]
set id2
[
r XADD mystream * b 2
]
set id3
[
r XADD mystream * c 3
]
r XGROUP CREATE mystream mygroup 0
# Client 1 reads item 1 from the stream without acknowledgements.
# Client 2 then claims pending item 1 from the PEL of client 1
set reply
[
r XREADGROUP GROUP mygroup client1 count 1 STREAMS mystream >
]
assert
{[
llength
[
lindex $reply 0 1 0 1
]]
== 2
}
assert
{[
lindex $reply 0 1 0 1
]
eq
{
a 1
}}
r debug sleep 0.2
set reply
[
r XCLAIM mystream mygroup client2 10 $id1
]
assert
{[
llength
[
lindex $reply 0 1
]]
== 2
}
assert
{[
lindex $reply 0 1
]
eq
{
a 1
}}
set reply
[
r XPENDING mystream mygroup - + 10
]
assert
{[
llength
[
lindex $reply 0
]]
== 4
}
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
{}
{
set master
[
srv -1 client
]
set master
[
srv -1 client
]
set master_host
[
srv -1 host
]
set master_host
[
srv -1 host
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment