How Distributed Transactions Work

Microsoft Distributed Transaction Coordinator (MS DTC) supports transactions that are distributed across two or more Windows 95 or Windows NT systems. Each system has a local transaction manager. All applications and resource managers communicate with their local transaction managers. The transaction managers cooperatively manage transactions that span systems.

When a request arrives with a new transaction, a relationship is established between the two systems. The system making the request informs its local transaction manager that the transaction has an outgoing relationship to the transaction manager on the second system. Similarly, the system receiving the request informs its local transaction manager that the transaction has an incoming relationship with the transaction manager on the first system.

These outgoing and incoming relationships form a tree of transaction manager relationships called the transaction's commit tree. The enlisted resource managers are also members of this commit tree: they have an outgoing and incoming relationship to their local transaction manager.

When a distributed transaction commits or aborts, the prepare, commit and abort messages flow outward on the commit tree. Any node of the tree can unilaterally abort a transaction anytime before it agrees to the prepare request sent in the first phase. Once a node has prepared, it remains prepared and in-doubt until the commit coordinator tells it to commit or abort the transaction. The root transaction manager of the commit tree is called the global commit coordinator. This coordinator makes the decision to either commit or abort the transaction and is never in doubt.

If a computer fails, then restarts, the transaction manager at that computer tries to determine the outcome of all in-doubt transactions in which it participated.

The transaction manager reads its log file to determine the outcomes of transactions for which it was the commit coordinator:

  1. For incoming transactions from other systems, the transaction manager determines if it was previously notified of the transaction's outcome.
  2. For incoming transaction that remain in-doubt, the transaction manager queries the incoming transaction manager to learn the transaction's outcome.

The transaction manager also responds to queries from other transaction managers regarding in-doubt outgoing transactions sent to them, similar to the protocol that transaction managers and resource managers follow at restart. The transaction manager determines the outcome of each in-doubt transaction and informs the resource managers of the transaction's outcome.

System or communication failures can leave transactions in-doubt for extended periods of time. While a transaction is in-doubt, the resources modified by the transaction remain locked and unavailable to others. The system operator can use the graphical management interface at the commit coordinator system to resolve transactions that remain in-doubt, or at the in-doubt system to force the transaction to either commit or abort. When the systems reconnect, MS DTC will detect these operator actions and flag any inconsistent actions.