Skip to main content

Distributed and nested distributed transactions

Short answer

A distributed transaction spans multiple servers, requiring atomic commit to ensure all-or-nothing semantics, e.g., inter-bank transfer. A nested distributed transaction decomposes into sub-transactions at different servers that run concurrently and provisionally commit; only the top-level commit makes them permanent, allowing independent aborts, e.g., trip booking with flight and hotel.

Define distributed transaction and nested distributed transaction with examples.

Distributed transaction

A distributed transaction is a transaction whose operations access objects managed by several servers. It can be flat (the client makes requests one after another to different servers) or nested. It must still satisfy ACID, so all servers must commit or all abort, which needs a coordinator and an atomic commit protocol (two-phase commit).

Example: a funds transfer where account A is at Bank server X and account B is at server Y.

Client --begin--> Coordinator (X)
   T: X.withdraw(A,100)
   T: Y.deposit(B,100)
Client --commit--> 2PC between X and Y

When server Y is first used, it joins the transaction by informing the coordinator, which keeps a list of participants.

Nested distributed transaction

A nested distributed transaction is a transaction with a tree of sub-transactions in which the sub-transactions run on different servers. Each sub-transaction can run in parallel at its server, can abort independently, and commits provisionally; the real commit happens only when the top-level transaction commits (using a nested two-phase commit that involves all servers).

Example: a book trip transaction T starts sub-transactions T1 (flight at server F), T2 (hotel at server H), T3 (taxi at server C). T2 may abort if no room, and T can then try another hotel.

            T (client)
        /     |      \
 T1 (F)   T2 (H)    T3 (C)

Each server records the sub-transactions it holds; the coordinator of the top level finds out which participants did work (and which provisionally committed or aborted) before running the commit protocol. Rules: if the parent aborts, all children abort; a child's locks pass to the parent when it commits.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Distributed System chapter 8 questions →