Skip to content

fix(eventing): back off outbox retries and make dead-letters recoverable#1336

Merged
iammukeshm merged 1 commit into
fullstackhero:mainfrom
marcelo-maciel:fix/outbox-backoff-redrive
Jul 13, 2026
Merged

fix(eventing): back off outbox retries and make dead-letters recoverable#1336
iammukeshm merged 1 commit into
fullstackhero:mainfrom
marcelo-maciel:fix/outbox-backoff-redrive

Conversation

@marcelo-maciel

Copy link
Copy Markdown
Contributor

Fixes audit finding REL-02.

Problem

A failing outbox message was retried on every dispatch cycle (~10s) with no backoff, hit IsDead after 5 attempts in ~50s, and was then lost: IsDead appears only in the store/entity/migrations — there was no replay path and no metric, only a log line. So a persistently failing integration event hammered the bus for ~50s and then silently vanished.

Fix

  • Backoff — new NextRetryAt column with exponential backoff (base * 2^(n-1), default base 30s, cap 1h; both configurable via EventingOptions). GetPendingBatchAsync skips messages whose NextRetryAt is still in the future, so retries space out instead of re-firing each cycle.
  • RecoveryIOutboxStore.GetDeadLetteredAsync lists dead-lettered messages and RedriveDeadLettersAsync(ids?) resets them (clears IsDead/RetryCount/LastError/NextRetryAt) for another attempt.
  • Observability — a new OpenTelemetry meter FSH.Eventing with fsh.eventing.outbox.deadlettered and fsh.eventing.outbox.redriven counters, registered in the OTel setup, so dead-lettering is alertable rather than only visible via the existing Error log.

Migration

Additive only: a nullable NextRetryAt column on OutboxMessages (Identity schema — the sole outbox-backed context). No drops, expand-safe.

Tests

OutboxRetryTests (Testcontainers, real Postgres via the Identity store): a non-dead failure schedules a future NextRetryAt and is excluded from the pending batch; a redrive resets a dead-lettered message and makes it pending again. Full Integration suite green (732 passed).

Follow-up

Redrive is exposed as a store API; wiring an admin endpoint or fsh CLI verb to trigger it operationally is a small follow-up. Docs changelog entry to follow.

REL-02: a failing outbox message was retried on every dispatch cycle (~10s) with no
backoff, hit IsDead after 5 tries in ~50s, and was then lost — no replay path and no
metric, only a log line.

- Add NextRetryAt with exponential backoff (base 30s, cap 1h; configurable via
  EventingOptions). The dispatch batch skips messages whose NextRetryAt is in the future.
- Add IOutboxStore.GetDeadLetteredAsync + RedriveDeadLettersAsync to inspect and reset
  dead-lettered messages for another attempt.
- Add an OpenTelemetry meter (FSH.Eventing) with dead-letter and redrive counters so the
  condition is alertable, not just greppable in logs.

Additive migration (nullable NextRetryAt column, Identity schema). Redis/infra unchanged.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@iammukeshm
iammukeshm merged commit d2d741f into fullstackhero:main Jul 13, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants