From a71e8148533449097b12233fbebafef135fd4a80 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 10 Jul 2018 11:19:06 +0200 Subject: [PATCH] Streams: send an error to consumers blocked on non-existing group. To detect when the group (or the whole key) is destroyed to send an error to the consumers blocked in such group is a problem, so we leave the consumers listening, the sysadmin is free to create or destroy groups assuming she/he knows what to do. However a client may be blocked in a given consumer group, that is later destroyed. Then the stream receives new elements. In that case there is no sane behavior to serve the consumer... but to report an error about the group no longer existing. More about detecting this synchronously and why it is not done: 1. Normally we don't do that, we leave clients blocked for other data types such as lists. 2. When we free a stream object there is no longer information about what was the key it was associated with, so while destroying the consumer groups we miss the info to unblock the clients in that moment. 3. Objects can be reclaimed in other threads where it is no longer safe to do client operations. --- src/blocked.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/blocked.c b/src/blocked.c index e62d75485..2a349f0a4 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -387,7 +387,11 @@ void handleClientsBlockedOnKeys(void) { /* If the group was not found, send an error * to the consumer. */ if (!group) { - /* XXX: Fixme, send the error. */ + addReplyError(receiver, + "-NOGROUP the consumer group this client " + "was blocked on no longer exists"); + unblockClient(receiver); + continue; } else { *gt = group->last_id; }