How Per-Pod Consumer Names Left 1,847 Redis Streams Messages Pending Forever and Dropped Order Confirmations
← Back
November 20, 2026Redis8 min read

How Per-Pod Consumer Names Left 1,847 Redis Streams Messages Pending Forever and Dropped Order Confirmations

Published November 20, 20268 min read

09:12 UTC, Thursday. A support ticket lands in the channel: "Customer paid yesterday, no confirmation email, can you resend?" By 09:40 there are nine more tickets like it. Payments look fine. The orders exist. The emails do not.


the scramble

Two of us get pulled in, me and someone from support engineering. Order confirmations go through a Redis stream called orders:confirm. The checkout service appends an entry, and a worker deployment reads it through a consumer group and calls the email provider.

First theory was the email provider. We check their status page (green) and our send logs. The logs show that the worker sends confirmations normally, about 11 per minute. So it is not "all emails fail". Roughly one order in forty never gets one.

Second theory: checkout stopped publishing for some orders. I compare order IDs from Postgres against entries in the stream with XRANGE. Every missing-email order has an entry in the stream. The messages were published. Nobody sent them.


the hunt

Dead end one: Redis eviction. The instance runs with maxmemory-policy noeviction and sits at 38% of its limit, so no entries were dropped. Dead end two: worker crashes. The worker deployment has had 0 restarts in 6 days, though it was redeployed four times in that window, which turned out to matter.

Then I ask the stream directly how far behind each consumer is:

127.0.0.1:6379> XINFO GROUPS orders:confirm 1) name: confirmers consumers: 9 pending: 1847 last-delivered-id: 1763629804117-0 entries-read: 214093 lag: 0

lag: 0 means the group has read everything. pending: 1847 means 1,847 messages were delivered and never acknowledged. And there are 9 consumers, though the deployment runs 3 replicas.

127.0.0.1:6379> XINFO CONSUMERS orders:confirm confirmers 1) name: confirm-worker-7d9f8b6c5-x2kqp pending: 0 idle: 2113 2) name: confirm-worker-7d9f8b6c5-m8vzt pending: 0 idle: 1980 3) name: confirm-worker-7d9f8b6c5-q4nrl pending: 0 idle: 2204 4) name: confirm-worker-6b4c7d9f8-h5wjd pending: 412 idle: 190455000 5) name: confirm-worker-6b4c7d9f8-t7pcs pending: 388 idle: 190455000 ...

Consumer names were built from the pod hostname. Every deploy creates new pod names, which creates new consumers. Old consumers stay in the group forever with whatever they had in flight at the moment their pod received SIGTERM.


the find

The worker loop reads with XREADGROUP ... STREAMS orders:confirm >. The special ID > means "only messages never delivered to any consumer in this group". A message that was delivered to a consumer and never acknowledged is not new, so > will never return it again. It stays in that consumer's pending entries list until somebody claims it.

Our workers handled SIGTERM by exiting right away. A pod that was mid-send during a rollout had read a message, started the HTTP call to the email provider, and been killed before the XACK. Four deploys in six days, a few in-flight messages each time, plus a couple of crashes during a node drain, adds up to 1,847. The new pods had different names, so nobody was ever going to retry what the old pods left behind.

The old code:

const consumer = `confirm-worker-${os.hostname()}`; while (running) { const res = await redis.xReadGroup( 'confirmers', consumer, [{ key: 'orders:confirm', id: '>' }], { COUNT: 10, BLOCK: 5000 } ); for (const msg of res?.[0]?.messages ?? []) { await sendConfirmation(msg.message); await redis.xAck('orders:confirm', 'confirmers', msg.id); } }

the fix

Two changes. First, drain the backlog by hand. XAUTOCLAIM transfers ownership of entries idle longer than a threshold to a consumer of your choosing, so I ran it from a one-off script with a 60-second minimum idle time and processed the result like normal traffic. Sends are keyed by order ID in the email provider's idempotency header, so reprocessing a message that did go out is harmless.

Second, make the worker claim abandoned work itself. A sweeper runs every 30 seconds inside each worker:

async function sweep() { let cursor = '0-0'; do { const { nextId, messages } = await redis.xAutoClaim( 'orders:confirm', 'confirmers', consumer, 60_000, // only entries idle for 60s+ cursor, { COUNT: 50 } ); for (const msg of messages) { if (!msg) continue; // deleted entries come back as null await sendConfirmation(msg.message); await redis.xAck('orders:confirm', 'confirmers', msg.id); } cursor = nextId; } while (cursor !== '0-0'); }

Also on shutdown: the worker now stops reading on SIGTERM, finishes the batch it holds, acknowledges, and only then exits. Once the backlog was drained I removed the 6 dead consumers with XGROUP DELCONSUMER. Deleting a consumer that still has pending entries discards those entries' ownership, so I did it only after XPENDING showed 0 for each of them.


the aftermath

The backlog drain sent 1,847 confirmations over about 14 minutes, the oldest from 6 days earlier. Support closed all the tickets by the afternoon. Because the provider's idempotency key covered us, 212 of those turned out to be messages whose email had already gone out, and the provider deduplicated them.

What changed afterward:

  • A Prometheus alert on pending from XINFO GROUPS staying above 20 for 5 minutes. This would have fired on day one.
  • A second alert on the oldest pending entry's idle time exceeding 10 minutes.
  • The runbook now says: if a stream group shows lag: 0 but work is missing, check pending before anything else.
  • Graceful shutdown with a 30-second terminationGracePeriodSeconds on the worker pods.

Every dashboard we had was green because lag was zero. Lag only counts what nobody has read yet. It says nothing about what somebody read and dropped.

Share this
← All Posts8 min read