• guybe7's avatar
    XREADGROUP: Unblock client if stream is deleted (#10306) · 2a295408
    guybe7 authored
    Deleting a stream while a client is blocked XREADGROUP should unblock the client.
    
    The idea is that if a client is blocked via XREADGROUP is different from
    any other blocking type in the sense that it depends on the existence of both
    the key and the group. Even if the key is deleted and then revived with XADD
    it won't help any clients blocked on XREADGROUP because the group no longer
    exist, so they would fail with -NOGROUP anyway.
    The conclusion is that it's better to unblock these clients (with error) upon
    the deletion of the key, rather than waiting for the first XADD. 
    
    Other changes:
    1. Slightly optimize all `serveClientsBlockedOn*` functions by checking `server.blocked_clients_by_type`
    2. All `serveClientsBlockedOn*` functions now use a list iterator rather than looking at `listFirst`, relying
      on `unblockClient` to delete the head of the list. Before this commit, only `serveClientsBlockedOnStreams`
      used to work like that.
    3. bugfix: CLIENT UNBLOCK ERROR should work even if the command doesn't have a timeout_callback
      (only relevant to module commands)
    2a295408
blockonkeys.tcl 8.17 KB