Course contentsShow
← Software Engineering
Lesson 1369 of 1,93340. Event-Driven ArchitectureFree lesson

Forward Recovery vs Backward Recovery

Choosing between retrying forward to completion or rolling back through compensations when steps fail.

Forward Recovery vs Backward Recovery

What you'll learn: How to decide whether to push forward and retry a failed step or roll back with compensating actions in a saga.

The Core Decision

When a saga step fails, you face a fundamental choice: should you retry forward (attempt the operation again until it succeeds) or roll back (undo completed steps using compensating transactions)?

Forward recovery means persisting through the failure by retrying the failed step, possibly with exponential backoff or adjusted parameters. You're betting that the failure is temporary—maybe a network hiccup, a temporarily unavailable service, or a transient resource constraint.

Backward recovery means abandoning the original goal and executing compensating transactions for all previously completed steps. You're accepting defeat and cleaning up the mess you've already made.

When to Choose Each

Choose forward recovery when:

  • The failure is likely transient (network timeout, temporary unavailability)
  • The operation is idempotent (safe to retry)
  • You have high confidence eventual success is possible
  • The business requirement demands completion

Choose backward recovery when:

  • The failure is semantic or permanent (business rule violation, insufficient funds)
  • Forward progress is impossible or unlikely
  • Continuing would waste resources or time
  • The user or system explicitly cancels the operation

The Analogy

Think of booking a vacation package: if the hotel reservation fails due to a network glitch, you retry (forward recovery). But if it fails because the hotel is permanently closed, you cancel the flight and car rental you already booked (backward recovery).

Many sagas implement a hybrid approach: retry forward a limited number of times, then roll back if retries are exhausted.

Key Takeaway: Forward recovery retries failed steps toward completion; backward recovery compensates successful steps to undo progress. Choose based on whether the failure is transient or permanent.