Skip to main content
InterviewHubPRO
Section Overview
Q23

Question 23 of 50

Part 3: Advanced Architecture & Production Patterns (Senior / Lead)

46%
Domain-Driven Design (50 Qs)•Part 3: Advanced Architecture & Production Patterns (Senior / Lead)

What are Compensating Transactions in Sagas?

senior LevelState ManagementSystem DesignDatabases & SQL

In Simple Words: Because distributed transactions cannot execute a database ROLLBACK across independent microservices, Sagas use compensating actions:

  • A compensating transaction is an explicit business operation that semantically reverses a prior committed action:
    • Original action: CreditCardCharged ($100) -> Compensating action: RefundIssued ($100).
    • Original action: SeatReserved (Seat 4A) -> Compensating action: SeatReleased (Seat 4A).
  • Leaves an immutable audit trail showing the attempt, failure, and compensation.