Email copiado — support@tuurt.com
Cargando experiencia
arquitectura · November 11, 2026 · 7 min

The Saga pattern: coordinating rollback between .NET and Node services without a distributed transaction

The Saga pattern replaces the classic distributed transaction with a sequence of local steps and their compensations. We cover orchestration vs choreography and the mistake of designing rollback after the happy path already works.

By Tuurt Team

The Saga pattern: coordinating rollback between .NET and Node services without a distributed transaction

Whenever a business operation touches more than one service — reserving inventory in a .NET service, charging a payment in a Node service, notifying an external provider — the same question comes up: what happens if the third step fails after the first two already committed? Inside a monolith with a single database, the answer is to wrap everything in an ACID transaction and roll back if anything goes wrong. Across services on different stacks, each with its own database, that option doesn't exist. There's no BEGIN TRANSACTION spanning a .NET service and a Node service at once, and the protocols that try — two-phase commit across heterogeneous databases — bring a coupling and locking cost that almost no real system can afford. That's where the Saga pattern comes in.

What a Saga is, and what it replaces

A Saga breaks a business operation into a sequence of local steps, each with its own transaction inside its own service, and defines a compensating action for every step: an operation that undoes that step's effect if something later in the sequence fails. There's no automatic rollback, because there's no transaction spanning the whole thing. What exists instead is a chain of forward steps and, if something fails, a chain of compensations running backward, triggered explicitly by code we write.

That reframes the design question. It's no longer "how do I roll this back", because there's no rollback in the database sense. It's "what operation, run afterward, leaves the system in a state equivalent to this step never having happened?" For reserving inventory, the compensation is releasing that reservation. For charging a payment, the compensation is a refund or a charge reversal — not an "undo" in the literal sense: the charge happened, and it gets recorded as reversed.

Orchestrated vs choreographed

There are two ways to coordinate a Saga's steps.

In an orchestrated Saga, a central component — the orchestrator — knows the full sequence of steps, calls each service in order, and decides which compensations to run and in what order when something fails. The orchestrator is the single place where the "what happens if this step fails" logic lives, which makes the whole flow easy to reason about by reading one component.

public class CreateOrderSaga
{
    public async Task ExecuteAsync(OrderRequest request)
    {
        var reservation = await _inventoryClient.ReserveAsync(request.Items);
        try
        {
            var charge = await _paymentsClient.ChargeAsync(request.Amount, request.PaymentMethod);
            try
            {
                await _notificationsClient.NotifyVendorAsync(request.VendorId, reservation.Id);
            }
            catch (Exception)
            {
                await _paymentsClient.RefundChargeAsync(charge.Id);
                await _inventoryClient.ReleaseReservationAsync(reservation.Id);
                throw;
            }
        }
        catch (Exception)
        {
            await _inventoryClient.ReleaseReservationAsync(reservation.Id);
            throw;
        }
    }
}

In a choreographed Saga, there's no orchestrator: each service reacts to events published by the others and decides on its own what to do, including whether to compensate. The inventory service reserves stock and publishes InventoryReserved; the payments service listens for that event, charges the customer, and publishes PaymentCharged or PaymentFailed; if the notifications service fails, it publishes NotificationFailed, and both payments and inventory listen for that event to compensate their own step.

eventBus.on('NotificationFailed', async (event) => {
  await paymentsService.refundCharge(event.chargeId);
});

Choreography avoids the single coupling point that an orchestrator represents, but it spreads the "what happens if this fails" logic across every participating service, and that logic only makes sense in full once you read all of them together. With three steps, that's manageable. With six or seven, mentally reconstructing the whole flow — and especially every combination of what failed after what — becomes the main maintenance cost of the system. Our rule of thumb: choreography for two- or three-step Sagas where the services already talk to each other through events; orchestration as soon as a fourth step or a conditional branch shows up, because at that point having the full sequence in one place is worth more than avoiding coupling to an orchestrator.

The mistake we keep seeing: designing compensation as an afterthought

The most expensive mistake isn't picking the wrong coordination style. It's treating compensations as a detail to bolt on once the happy path already works. When a team designs "reserve, charge, notify" first and leaves the question of how to undo each step for a later iteration, it almost always discovers at that point that one of the steps isn't actually compensable with the information the happy path decided to keep.

The typical case is the payment charge. If the payments service only records "charge succeeded, amount X," compensating it later requires knowing exactly which transaction to reverse, through which gateway, and whether that gateway even supports partial reversal or only full reversal. If that information wasn't captured at charge time — the provider's transaction ID, the method used, whether it was a one-off charge or the first of a series — the compensation turns into a manual reconciliation problem instead of an API call. Compensation isn't symmetric to the original step by definition; it's symmetric only if the original step stored what's needed to make it so, and that has to be decided while designing the forward step, not afterward.

The same applies to steps with irreversible external effects. You can't "un-send" a vendor notification email. The compensation there isn't undoing the step, it's a different action that mitigates the consequence: sending a follow-up cancellation notice. If the Saga's design doesn't account for this from the start, the notification step ends up being the one that breaks the whole compensation chain, because there's no action that reverses it, only one that softens it — and the compensation code for earlier steps wrongly assumes every step can be cleanly undone.

Idempotency of compensations

A compensation can run more than once: an orchestrator retrying after a network timeout, or a choreography event processed twice because the broker delivered it duplicated. Calling ReleaseReservationAsync on a reservation that was already released, or RefundChargeAsync on a charge that was already refunded, must not fail or double the effect. In practice, this means every compensating action needs the same idempotency guarantee as any write endpoint exposed to retries: an idempotency key based on the original operation's ID, and a status check before applying the effect, not just before responding.

What didn't work the first time

In an order-creation flow between a .NET inventory service and a Node payments service, the first design was choreographed, because both services already published domain events for other purposes and adding two more felt like the path of least effort. It worked fine while the flow only had those two steps. Once we added a third service to validate credit limits before charging, with a branch that could require manual approval for large amounts, the logic for what to compensate under each failure combination ended up spread across three separate codebases, and a production bug — an inventory reservation that never got released when manual approval was rejected — took longer to diagnose than to fix, because no one could see the full flow in one place.

We migrated that Saga to an orchestrated design, with a dedicated service that calls all three participants in sequence and centralizes all the compensation logic. Diagnosis time for similar incidents dropped noticeably, not because an orchestrator is inherently more reliable, but because anyone on the team can read a single file and reconstruct what should have happened, instead of correlating logs across three different services to piece together the real sequence of events.

What we check before signing off on a Saga

Before closing out a Saga's design, we confirm that every forward step explicitly stores the information its compensation will need, not just what the happy path requires to move forward. We verify that every compensating action is idempotent against retries and duplicate deliveries, held to the same standard we apply to any write endpoint. And we go step by step checking whether any of them lacks a real possible compensation — an irreversible external effect — and if one does, we explicitly design the mitigating action instead of leaving a gap in the chain that someone will only discover once it fails in production.

saga microservices dotnet nodejs
← Back to blog