Locking, Streams & Scripting — Series 2

Preview — 3 of 10 questions

What does XGROUP CREATE mystream mygroup $ do, and what does the $ mean?

javascript
XADD orders * item "widget"    -- entry 1 (before the group exists)
XGROUP CREATE orders processors $
XADD orders * item "gadget"    -- entry 2 (after the group exists)

XREADGROUP GROUP processors worker1 COUNT 10 STREAMS orders >
-- only returns entry 2 ("gadget")  entry 1 is invisible to this group
A$ tells the group to start reading from the END of the stream — only NEW messages added after group creation will be delivered to consumers in this group; existing messages already in the stream are skipped
B$ means the group starts reading from the very beginning of the stream, delivering every existing message
C$ is a wildcard matching all stream keys with a similar name
DXGROUP CREATE requires the stream to already have at least one consumer registered

A consumer crashed while holding several pending (unacknowledged) messages. How does another consumer take over processing those messages?

javascript
-- Explicit claim of specific message IDs, idle for at least 30 seconds
XCLAIM orders processors worker2 30000 1718000000000-0 1718000000001-0

-- Simpler: let Redis find and claim eligible messages automatically
XAUTOCLAIM orders processors worker2 30000 0
APending messages are automatically reassigned to any available consumer after 1 second, with no explicit command needed
BXCLAIM stream group new-consumer min-idle-time id1 id2 — transfers ownership of specific pending message IDs to new-consumer, but only if they've been idle (unacknowledged) for at least min-idle-time milliseconds, preventing premature claiming of messages still being actively processed; XAUTOCLAIM does the same but automatically scans for eligible messages instead of requiring explicit IDs
CXDEL must be used to remove the crashed consumer's pending messages before any other consumer can process new ones
DOnce a consumer crashes, its pending messages are permanently lost and cannot be reclaimed

What does the summary form of XPENDING mystream mygroup return (called with no ID range)?

javascript
XPENDING orders processors
1) (integer) 3                         -- total pending count
2) "1718000000000-0"                    -- smallest pending ID
3) "1718000000005-0"                    -- largest pending ID
4) 1) 1) "worker1"                       -- per-consumer breakdown
      2) "2"
   2) 1) "worker2"
      2) "1"
AIt immediately returns the full message payload for every pending entry
BXPENDING with no arguments deletes all pending entries for the group
CIt returns an overview: total pending count, the smallest and largest pending IDs, and a per-consumer breakdown of how many messages each consumer has pending — useful as a quick health check before drilling into the extended form (with an ID range and count) for full detail on each specific pending entry
DThe summary form only works if the consumer group has exactly one consumer

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.