The Problem Choreography Hides
Saga choreography distributes transaction coordination across services by having each participant emit domain events that trigger the next step. There is no central orchestrator holding state. That decentralization is both the design's strength and its principal failure surface.
In a linear happy path, choreography is elegant. Under partial failure it exposes a category of bugs that are hard to detect, expensive to recover from, and nearly invisible in standard observability: the partial rollback trap.
This article covers the mechanics of that trap, what compensation boundaries actually mean at the storage and event level, how poison events corrupt saga state silently, and how to instrument and design choreographed sagas so recovery is deterministic.
Choreography Topology and Its Implicit State Machine
Consider an order fulfillment saga with four participants: order-service, inventory-service, payment-service, and fulfillment-service. Each publishes events to a shared bus (Kafka, SQS, EventBridge). Each subscribes to events from predecessors.
OrderPlaced → inventory.Reserved → payment.Captured → fulfillment.Scheduled → order.Confirmed The saga's state exists implicitly in the sequence of events that have been successfully consumed and processed. No single process holds a saga state machine. This means:
- No authoritative rollback coordinator. When
payment.Capturedsucceeds butfulfillment.Scheduledfails, the compensation signal must travel backward through the chain. Each service must react to a compensation event it was not primarily designed around. - State reconstruction requires event replay. To know whether a saga is in a compensable state, you must correlate events by
sagaIdacross multiple topics and services. - Compensation is not symmetric.
inventory.Reservecan be compensated byinventory.Release. Butpayment.Captureon a card network is a real-money operation. Compensation may be a refund, not an undo — with its own failure modes.
The Partial Rollback Trap
The trap occurs when a compensation event is published, consumed, and acknowledged — but the compensating action fails idempotently in a way the consumer does not surface as an error.
Consider this Go handler in inventory-service:
func (h *InventoryHandler) HandleOrderCancelled(ctx context.Context, event OrderCancelledEvent) error { ok, err := h.repo.ReleaseReservation(ctx, event.SagaID, event.SKU, event.Quantity) if err != nil { return fmt.Errorf("release reservation: %w", err) } if !ok { // Reservation not found — treat as already released return nil } return h.publisher.Publish(ctx, InventoryReleasedEvent{SagaID: event.SagaID}) } The !ok branch silently swallows a missing reservation. This is correct if the reservation was never made. It is catastrophically incorrect if the reservation was made but the release failed for a transactional reason (e.g., the write hit a MongoDB write conflict and ReleaseReservation returned false instead of an error due to a bug in result mapping).
The compensation event is acknowledged. InventoryReleasedEvent is emitted. Upstream services believe compensation succeeded. The inventory is never actually released. The saga appears complete. The stock is permanently understated.
This is the partial rollback trap. The saga's distributed state machine transitions to "compensated" but the system state does not match.
Compensation Boundary Design
A compensation boundary is the set of writes — database mutations, outbox inserts, external API calls — that must all succeed for a compensation to be considered durable. Boundaries must be:
Transactionally Atomic Where Possible
For MongoDB-backed services, use a single-document write that atomically updates the reservation status and inserts an outbox record:
func (r *ReservationRepo) ReleaseReservation(ctx context.Context, sagaID, sku string, qty int) (bool, error) { session, err := r.client.StartSession() if err != nil { return false, err } defer session.EndSession(ctx) var released bool _, err = session.WithTransaction(ctx, func(sctx mongo.SessionContext) (interface{}, error) { res, err := r.reservations.UpdateOne(sctx, bson.M{"saga_id": sagaID, "sku": sku, "status": "reserved"}, bson.M{"$set": bson.M{"status": "released"}}, ) if err != nil { return nil, err } if res.MatchedCount == 0 { released = false return nil, nil } // Insert outbox record in same transaction _, err = r.outbox.InsertOne(sctx, OutboxRecord{ SagaID: sagaID, EventType: "inventory.released", Payload: mustMarshal(InventoryReleasedEvent{SagaID: sagaID}), }) released = true return nil, err }) return released, err } The outbox pattern ensures the event is only published if the reservation update committed. The relay process polls and publishes; at-least-once delivery is handled by the relay, not the handler.
Idempotent on Redelivery, Not Silent on Missing State
The critical distinction: idempotency means executing the same compensation twice produces the same final state. It does not mean treating missing state as success. The handler must distinguish:
- Already compensated: reservation exists with
status: released→ idempotent, emit event - Never existed: no document with
sagaId→ this is anomalous, dead-letter it - Compensation failed: error returned → retry
switch { case status == "released": // Already compensated, re-emit if outbox not yet processed return h.ensureOutboxEntry(ctx, event.SagaID) case status == "": // Document missing entirely — route to DLQ for investigation return ErrSagaStateNotFound default: // Attempt release } Poison Events in Compensation Chains
A poison event is a compensation event that cannot be processed, causes the consumer to crash or enter an error loop, and blocks downstream compensation from proceeding.
In Kafka-backed choreography, a poison event on a partition stops all saga compensation on that partition. With SQS, visibility timeout expiration causes redelivery; a crashing consumer creates unbounded redelivery cycles that exhaust the maxReceiveCount and dead-letter the event — silently terminating compensation.
Sources of poison events in compensation chains:
- Schema mismatch: compensating event schema evolved without backward compatibility. The consumer panics or returns a parse error.
- Missing correlating data: the event carries a
sagaIdthat never existed in this service's storage (cross-region routing bug, or the service was added to the saga after some events were already in-flight). - Compensation ordering violation:
inventory.Releasedarrives beforeinventory.Reservedwas processed (network partition during forward flow, then recovery during reverse flow).
Detection and Quarantine
Each compensation handler should write a structured log entry with saga_id, event_type, compensation_step, and result (success, skipped, failed, quarantined). A Prometheus counter on result=quarantined with a burn rate alert catches systemic poison event injection faster than DLQ depth monitoring, which lags by the full visibility timeout cycle.
Saga State Externalization for Recovery
Fully implicit saga state makes post-incident recovery expensive. A lightweight saga log — not a full orchestrator — is a practical middle ground.
Each service, upon processing any saga event, upserts a record into a shared saga_events collection or Redis sorted set keyed by sagaId:
saga:{sagaId}:events → sorted set scored by event timestamp members: "order.placed", "inventory.reserved", "payment.captured", "fulfillment.failed", "payment.refunded", "inventory.released" This is append-only. No service mutates another's entries. A background reconciler queries sagas that have been in a non-terminal state for longer than the SLA (e.g., 10 minutes) and emits compensation triggers for the highest successfully completed forward step that lacks a corresponding compensation entry.
This reconciler is not an orchestrator — it does not drive the happy path. It is a recovery drain for sagas that stalled because a compensation event was lost, dead-lettered, or never emitted.
Decision Framework
Use choreography when:
- Participants are independently deployable and owned by separate teams
- Event coupling is acceptable and schemas are versioned
- Compensation operations are low-risk (idempotent inventory adjustments, cache invalidations)
Add orchestration when:
- Payment, external API calls, or irreversible operations are in the compensation path
- More than three compensation steps exist — the implicit state machine becomes unauditable
- You need deterministic timeout-based rollback with SLA enforcement
Always enforce:
- Outbox pattern for every forward and compensation event emission
- Explicit handling of
state not founddistinct fromalready compensated - Saga event log (even Redis-based) for reconciliation and incident forensics
- Burn rate alerts on
compensation_quarantinedandsaga_stalledmetrics, not just DLQ depth - Schema backward compatibility enforced at CI — not discovered in a compensation failure at 2am
The partial rollback trap is not a theoretical edge case. It is the natural consequence of treating compensation as symmetric undo rather than a first-class distributed operation with its own failure modes, state contract, and observability requirements.
