mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 23:31:03 +00:00
#5299 Fix blocking XREAD for streams that ran dry
The conclusion, that a xread request can be answered syncronously in case that the stream's last_id is larger than the passed last-received-id parameter, assumes, that there must be entries present, which could be returned immediately. This assumption fails for empty streams that actually contained some entries which got removed by xdel, ... . As result, the client is answered synchronously with an empty result, instead of blocking for new entries to arrive. An additional check for a non-empty stream is required.
This commit is contained in:
parent
d60c17cbb3
commit
c1e9186f06
@ -1436,7 +1436,7 @@ void xreadCommand(client *c) {
|
|||||||
* synchronously in case the group top item delivered is smaller
|
* synchronously in case the group top item delivered is smaller
|
||||||
* than what the stream has inside. */
|
* than what the stream has inside. */
|
||||||
streamID *last = &groups[i]->last_id;
|
streamID *last = &groups[i]->last_id;
|
||||||
if (streamCompareID(&s->last_id, last) > 0) {
|
if (s->length && (streamCompareID(&s->last_id, last) > 0)) {
|
||||||
serve_synchronously = 1;
|
serve_synchronously = 1;
|
||||||
*gt = *last;
|
*gt = *last;
|
||||||
}
|
}
|
||||||
@ -1444,7 +1444,7 @@ void xreadCommand(client *c) {
|
|||||||
} else {
|
} else {
|
||||||
/* For consumers without a group, we serve synchronously if we can
|
/* For consumers without a group, we serve synchronously if we can
|
||||||
* actually provide at least one item from the stream. */
|
* actually provide at least one item from the stream. */
|
||||||
if (streamCompareID(&s->last_id, gt) > 0) {
|
if (s->length && (streamCompareID(&s->last_id, gt) > 0)) {
|
||||||
serve_synchronously = 1;
|
serve_synchronously = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user