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
3f8a3efe
Commit
3f8a3efe
authored
Jul 10, 2018
by
dejun.xdj
Browse files
Streams: fix xreadgroup crash after xgroup SETID is sent.
For issue #5111.
parent
7239e9ca
Changes
1
Show whitespace changes
Inline
Side-by-side
src/t_stream.c
View file @
3f8a3efe
...
@@ -905,24 +905,29 @@ size_t streamReplyWithRange(client *c, stream *s, streamID *start, streamID *end
...
@@ -905,24 +905,29 @@ size_t streamReplyWithRange(client *c, stream *s, streamID *start, streamID *end
* will not require extra lookups. We'll fix the problem later
* will not require extra lookups. We'll fix the problem later
* if we find that there is already a entry for this ID. */
* if we find that there is already a entry for this ID. */
streamNACK *nack = streamCreateNACK(consumer);
streamNACK *nack = streamCreateNACK(consumer);
int retval = 0;
int retval
_group_tryins = 0, retval_consumer_tryins
= 0;
retval
+
= raxTryInsert(group->pel,buf,sizeof(buf),nack,NULL);
retval
_group_tryins
= raxTryInsert(group->pel,buf,sizeof(buf),nack,NULL);
retval
+
= raxTryInsert(consumer->pel,buf,sizeof(buf),nack,NULL);
retval
_consumer_tryins
= raxTryInsert(consumer->pel,buf,sizeof(buf),nack,NULL);
/* Now we can check if the entry was already busy, and
/* Now we can check if the entry was already busy, and
* in that case reassign the entry to the new consumer. */
* in that case reassign the entry to the new consumer. */
if (retval == 0) {
if (retval_group_tryins == 0) {
streamNACK *oldnack = raxFind(group->pel,buf,sizeof(buf));
serverAssert(oldnack != raxNotFound);
if (retval_consumer_tryins == 0) {
/* In this case, only need to update old nack
* delivery_time and delivery_count. */
oldnack->delivery_time = mstime();
oldnack->delivery_count++;
streamFreeNACK(nack);
streamFreeNACK(nack);
nack = raxFind(group->pel,buf,sizeof(buf));
} else {
serverAssert(nack != raxNotFound);
/* remove the old nack from original consumer */
raxRemove(nack->consumer->pel,buf,sizeof(buf),NULL);
raxRemove(oldnack->consumer->pel,buf,sizeof(buf),NULL);
/* Update the consumer and idle time. */
/* Overwrite nack in group pel. */
nack->consumer = consumer;
raxInsert(group->pel,buf,sizeof(buf),nack,NULL);
nack->delivery_time = mstime();
streamFreeNACK(oldnack);
nack->delivery_count++;
}
/* Add the entry in the new consumer local PEL. */
} else if (retval_group_tryins == 1 && retval_consumer_tryins == 0) {
raxInsert(consumer->pel,buf,sizeof(buf),nack,NULL);
} else if (retval == 1) {
serverPanic("NACK half-created. Should not be possible.");
serverPanic("NACK half-created. Should not be possible.");
}
}
...
...
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