Flat and Nested Distributed Transactions in Distributed System

Flat and Nested Distributed Transactions in Distributed System

In this tutorial you are going to learn about Flat and Nested distributed transactions in Distributed System.

Distributed Transaction

A transaction becomes distributed if it involves operations on several different servers.

  • Transaction end, it requires atomicity.
  • Atomicity involved commit or abort.
  • For transactions one of the servers takes on a coordinators rate, which involves ensuring the same outcome at all.

Flat Distributed Transaction

A flat client transaction completes each of its requests before going on to the next. Therefore, each transaction accesses server objects sequentially. In flat transactions, clients make requests to more than one server. It has a single start point and single end point.

Flat transactions send out requests to different servers and each request is completed before the client goes to the next. Transaction T is a flat transaction that invokes operation on objects in servers X, Y and Z.

Coordinator of the flat-distributed transaction:

Servers execute requests in a distributed transaction-

  • When it commits, they should communicate with each other in order to coordinate their actions
  • A client starts a transaction by sending an open-Transaction request to a coordinator in any server.
  • It returns a TID unique in a distributed system.
  • At the end, it will be responsible for committing or aborting it.
  • Each server managing an object accessed by the transaction is a participant – it joins the transaction
    1. A participant will be keeping the track of objects that is involved in the transaction
    2. At the end, it cooperates with the coordinator that is to carry out the commit.
  • Note that a participant can call abort Transaction in coordinator.

Nested Distributed Transaction

In nested transaction, the top level transaction can open sub-transaction and each sub-transaction down to any depth of nesting. In nested transactions, sub-transactions at the same level will run concurrently. T1 and T2 are concurrent. As T1 and T2 invoke objects in different servers, run in parallel.

Nested Transactions-

  • Nested transaction are structured in an invert-root tree.
  • The outermost transaction is the top-level transaction and others are sub-transactions.
  • A sub-transaction is atomic to its parent transaction.
  • Sub-transactions at the same level can run concurrently.
  • Each sub-transaction can fail independently of its parent and of the other sub-transactions.

A flat-client transaction completes each of its requests before going on to the next one. Therefore, each transaction accesses the server’s object sequentially. Requests can be run in parallel with several servers, the nested transactions are more efficient.

Advantages of Nested Transactions-

  • Additional concurrency in a transaction: Sub-transactions at one level may run concurrently with other sub-transactions.
  • More robust: Sub-transactions can commit or abort independently.
  • For example : A transaction to deliver a mail message to a list of recipients.

The rules for committing of nested transactions-

  • A transaction commits or aborts only after its child transactions have completed;
  • When a sub-transaction completes, it makes an independent decision on provisionally commit/abort. its decision to abort is final.
  • When a parent aborts, all of its sub-transactions are aborted, though some of them have provisionally committed.
  • When a sub-transaction aborts, the parent can decide to abort or not.
  • When the top-level transaction commits, then all of the sub-transactions that have provisionally committed can commit.


This article on Flat and Nested Distributed Transactions in Distributed System is contributed by Hemalatha P. If you like TheCode11 and would like to contribute, you can also write your article and mail to thecode11info@gmail.com

Previous Post Next Post

Contact Form