Make your own free website on Tripod.com

Microsoft Distributed Transaction Coordinator (MS-DTC)

Source : http://www.microsoft.com/sql/guide/inc/whtpprdtc_wpr_inc/intro_content.txt

© 1998 Microsoft Corporation. All rights reserved.

It is difficult to write applications. With time, we are discovering concepts and techniques that allow us to build large applications. Modularity, or structuring an application as independent modules, allows you to build complex systems from simpler parts and to get software reuse. Object-oriented concepts and the Microsoft® Component Object Model (COM) provide a technique that allows you to write modular applications.When an application is structured as components, the individual parts can reside together in a single computer, or they can interact by using remote-procedure calls across a network. So, components give both modularity and natural distribution.

Structuring an application into independent components can create the problem of managing the components. Monolithic programs fail and are restarted as a unit. But, with a modular system, the failure of one component must not corrupt the others. There must be a way to isolate faults and limit fault propagation. Transactions provide modular execution and thus simplify and automate fault handling. They provide a simple conceptual execution framework for both implementers and users.

The user thinks of a transaction as a single change event that either happens or doesn't happen. Implementers think of a transaction as a programming style that allows them to write modules that can participate in distributed computations. Suppose you want to transfer money from one bank account to another. The implementers and the users want to make sure that either both accounts change or neither changes. It is hard to make this work in a distributed system—computers can fail and messages can be lost. Transactions provide a way to bundle a set of operations into an atomic execution unit.

The atomic all-or-nothing property is not new: it appears throughout life. For example, if you enter a contract, an escrow officer coordinates the transaction: the escrow officer collects the signatures of each party to the contract. The contract is final when the escrow officer announces that everyone has signed. A minister conducting a marriage ceremony first asks the bride and groom, "Do you take this person to be your spouse?" If they both respond "I do," the minister pronounces them married. A director on a movie set first asks, "Ready on the set?" If all respond yes, the director then calls, "Action!" A helmsman on a sailboat preparing to tack first asks the crew, "Ready about?" If they all respond yes, then the helmsman shouts, "Helm's a'lee!" and turns the boat.

These scenarios illustrate the basic principle of a transaction: several independent entities must agree. If any party disagrees, the deal is off. Once they agree, the transaction can occur. The Microsoft Distributed Transaction Coordinator (MS DTC) performs this transaction coordination role for the other components of the COM architecture. In MS DTC terminology, the director is called the transaction manager. The participants in the transaction that implement transaction-protected resources, such as relational databases, are called resource managers.An application begins a transaction by calling the transaction manager's BeginTransaction method. This creates a transaction object that represents the transaction. The application then calls the resource managers to do the work of the transaction.

The application's first call to each resource manager identifies the application's current transaction. For example, if the application is using a relational database, it calls the ODBC interface, which associates the transaction object with the ODBC connection. Thereafter, all database calls made over that connection are performed on behalf of the transaction until the transaction is ended.

When a resource manager first does work on behalf of a transaction, it enlists in the transaction by calling the transaction manager. As the transaction progresses, the transaction manager keeps track of each of the resource managers enlisted in the transaction.

Typically, the application completes the transaction with a Commit transaction method. If the application is unable to complete the application calls the Abort transaction method, which undoes the transaction's actions. If the application fails, MS DTC aborts the transaction.

When the application successfully completes the transaction's work, it calls the MS DTC to commit the transaction. MS DTC then goes through a two-phase commit protocol to get all of the enlisted resource managers to commit. The two-phase commit protocol ensures that all the resource managers commit the transaction or all abort it. In the first phase, the MS DTC asks each resource manager if it is prepared to commit. If all participants say yes, then in the second phase MS DTC broadcasts the commit message to all of them. If any part of the transaction fails, if a resource manager fails to respond to the prepare request, or if a resource manager responds no, then MS DTC notifies all of the resource managers that the transaction aborted.

Transaction managers are a key part of most database systems. Transaction managers are also an optional part of some operating systems. Microsoft believes that transactions are essential for distributed applications—transactions provide modular execution, which complements COM's modular programming. So, Microsoft implemented transaction management software for both Microsoft® Windows® 95 and Microsoft® Windows NT® operating systems.

Combining the transaction concept with COM required innovation. Traditional transaction systems required considerable skill to install and manage. The challenge of integrating MS DTC with Microsoft's operating system was to automate installation, management, and use. Many of the concepts and techniques had to be reinvented for the new client/server, object-oriented, and visual management environments.

In its first release, MS DTC works with one resource manager: Microsoft® SQL Server™. It also operates with several transaction processing monitors, including Encina®, Top End®, and TUXEDO®. MS DTC implements the OLE transaction interfaces. All OLE transaction interfaces are public so that any resource manager can become an OLE transaction resource manager. In the future, Microsoft and other software companies will add other transactional resource managers, such as distributed object systems, transactional file systems, transaction queuing systems, and workflow management systems.

The ACID properties

Transactions provide the ACID properties.

Atomicity A transaction either commits or aborts. If a transaction commits, all of its effects remain. If it aborts, all of its effects are undone. For example, in renaming an object, the new name is created and the old name is deleted (commit), or nothing changes (abort).

Consistency A transaction is a correct transformation of the system state. It preserves the state invariants. For example, by adding an element to a doubly linked list, all four forward and backward pointers are updated.

Isolation Concurrent transactions are isolated from the updates of other incomplete transactions. These updates do not constitute a consistent state. This property is often called serializability. For example, a second transaction traversing the doubly linked list mentioned in the consistency example will see the list before or after the insert, but it will see only complete changes.

Durability Once a transaction commits, its effects will persist even if there are system failures. For example, after the rename in the atomicity example, the object will have the new name even if the system fails and reboots right after the commit completes.

It is up to the application to decide what consistency is and to bracket its computation with BeginTransaction and Commit transaction methods to delimit these consistent transformations. Transactional resource managers provide consistent, isolated, and durable transformations of the objects they manage. MS DTC manages transactions that involve multiple resource managers, perhaps distributed among multiple computers. MS DTC creates transaction objects, tracks migration of transactions among resource managers, and implements the two-phase commit protocol to make these transactions atomic and durable.


© 1998 Microsoft Corporation. All rights reserved. Terms of use.