gobridge

0019 — DLQ automatic redrive triggered by system events

Status: accepted Date: 2026-09-24 Deciders: GoBridge core Amends: 0017 (its redrive-batch consequence: each entry of an admin redrive batch now has its own bound) Relates to: 0015 (every rule of an admin redrive also holds for an automatic one), 0003 (the removed-subscription dead-letter this redrives)

Context

Some dead-letter records wait only for a condition the bridge can see for itself. The first case comes from the ADR 0003 addendum. When a configuration change removes a filter from a persistent or exclusive MQTT session, the broker can still hand the session deliveries for that filter. With a dead-letter store, the session writes each one to the store with error code SUBSCRIPTION_REMOVED and acknowledges it. A filter is often removed by mistake, or as one step of a staged migration, and then restored: the operator rolls the configuration back or enables the filter again. Until now the operator then had to find those records and redrive each one through the admin API, although the bridge already knows the filter is back.

A second problem sat in the admin redrive itself. One 30-second bound covered a whole redrive batch, and entries are redriven one after another. Since ADR 0017 a direct_hold route retries a failing send inside the bridge for its send_retry_budget (60 s by default). Against a destination that was down, the first entry of a batch could use all 30 seconds, and every later id came back redrive deadline exceeded before entry lookup without being tried.

Decision

The record says whether automation may redrive it

The first trigger and the record it redrives

The trigger is a session hook

One pass

  1. Wait until the runtime can deliver. Every second, on the runtime clock, the pass checks that the runtime is at least at readiness level subscribed and that the session’s single ingress route has a started route runner. When the runtime is ready but the session has no single ingress route (none, or several), the pass logs a warning and ends; the records stay for an operator. A shutdown ends the wait.
  2. One pass at a time. A lock is held for the whole pass (not for the wait), so two events cannot redrive one record twice.
  3. List. The pass lists that route’s records that failed inside the window, stores.dlq.auto_redrive_window: 24 hours by default, and 0s turns automatic redrive off. It lists only records that failed before the pass started or in its first millisecond, so a route that keeps dead-lettering during the pass cannot keep it paging; those records wait for the next event. The bound is exclusive and stores keep failed_at to the millisecond, so it sits one millisecond past the start: a record written in the pass’s own millisecond is still included. It reads pages of 100, oldest first, paging forward from the last failed_at it saw and skipping records it has already seen. It stops on a short page or on a page with nothing new. Each list call has its own 30-second bound.
  4. Redrive each match, oldest first, inject-then-delete with the rules of ADR 0015: a fresh envelope ID with a causation link to the original, the replay confined to the record’s binding, and a delete only after a confirmed inject. The inject runs under the runtime’s work context, so a shutdown abandons it and the record stays. The delete after a confirmed inject is not cancelled by a shutdown and has a 30-second bound; skipping it would redrive the message a second time. A failed delete is logged and recorded in the audit detail as delete_error; the record stays, and a later event may redrive it again (at-least-once).
  5. Audit and count. Each record is audited as dlq.redrive.auto: the actor is the runtime’s instance ID, the resource is dlq, the resource ID is the record ID, the outcome is success or failure, and the detail holds route_id, session_id, subscription, and error or delete_error. The counters DLQRedrives and DLQRedriveFailures move with the route_id tag, as for an admin redrive.

No second record for a temporary failure

An admin redrive injects a synthetic delivery whose Retry answers “not supported”. So a recoverable failure that the route would hand back to its source becomes a new retry_unsupported dead-letter record. On the automatic path that would add a record on every failed attempt. The automatic inject sets a hold option instead: Retry returns an error, the route returns that error without writing a record, and the original record stays the only one, unchanged.

When a redrive fails

Clustering

Admin redrive: a bound per entry

Consequences

Rejected alternatives