FFORGE//RS
← Roadmap

distributed systems / LEVEL 4

The compensation ran twice

EST.40 MIN
01

THEORY / RETRIEVAL

What to restore

  • Contrast saga compensation with atomic rollback and 2PC
  • Generate reverse-order idempotent compensation work
  • Handle duplicate completion evidence safely

A saga is a sequence of committed local transactions

When a later step fails, earlier effects are not magically rolled back. The system runs domain-specific compensations, which can fail, be retried and require manual repair. Every forward and compensating command needs durable state and idempotency.

2PC chooses a different trade-off

Two-phase commit asks participants to prepare before a coordinator decides commit or abort, providing a stronger atomic outcome among compatible participants. It adds coordination, blocking and operational coupling; it is not a universal replacement for sagas or outbox delivery.

CHECKPOINT

A payment refund in a saga times out after the provider accepted it. What property must the retry have?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / CODE REVIEW

Make the code safe

Return one compensation for each distinct completed step, in reverse completion order. Duplicate completion records come from at-least-once delivery and must not duplicate economic actions.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
1 / 64 KB
OUTPUT
Runner is waiting for a submission.