Freigeben über


What is MSDTC and why do I need to care about it?

I've been talking for a while about MSDTC and transactions without explaining them. I know many of you reading this blog already know the terms, but some of the developers just entering the enterprise space don't know if they should care or not about these subjects.

MSDTC is an acronym for Microsoft Distributed Transaction Coordinator. As the name says, MSDTC is a Windows service providing transaction infrastructure for distributed systems. In this case, a transaction means a general way of structuring the interactions between autonomous agents in a distributed system. Each transaction is a state transformation with four key properties - the ACID properties: Atomic (all or nothing), Consistent (legal), Isolated (independent of concurrent transactions) and Durable (once it happens, it cannot be abrogated). There are different techniques that implement the ACID properties but the most known one is two-phase commit.

In other words, transaction processing is a software technology that makes distributed computing reliable. You can see a transaction as a unit of work in which a series of operations occur. The transaction (with its ACID properties) is providing protection in the case when one or more of these operations fail at any point in time. By using transactions, you can vastly simplify the error recovery for your system.

The main actors in a transaction are: the transaction manager (MSDTC), the initiator (the application which started the transaction) and the resource managers (the entities that manage data and work). The flow of actions in a simplified form is:

1. The client application (the initiator) begins a transaction by requesting one from the transaction manager;

2. The client app asks the resource managers to do work as part of the same transaction; during this step, the resource managers register with the transaction manager for that transaction ("they enlist");

3. The client app commits the transaction;

4. The transaction manager coordinates with the resource managers to ensure that all succeed to do the requested work or none of the work if done, thus maintaining the ACID properties.

The main transactions standard currently supported by MSDTC is the OLE Transactions (or OleTx). MSDTC is also supporting other standards like XA (or X/Open Distributed Transaction Processing Standard) and TIP (Transaction Internet Protocol). In the future MSDTC will support WS-Coordination, WS-AtomicTransaction, and WS-BusinessActivity.

You can read more about MSDTC at https://msdn.microsoft.com/library/?url=/library/en-us/cossdk/htm/dtc_toplevel_6vjm.asp?frame=true.

If you are developing COM+ or System.EnterpriseServices components and you are using the Transaction service then you are indirectly using MSDTC. The COM+ infrastructure is hiding all the details from you so you can focus on your business needs instead of implementation details. If you need to bypass COM+ and talk directly to MSDTC you can do it using the MSDTC proxy (msdtcprx.dll). For now, to directly access MSDTC from .Net apps you need to use COM Interop. For future apps, please refer to my previous post about .Net and Transactions.

Comments

  • Anonymous
    March 04, 2004
    Hey dude...are you from Romania, right ?
    Nice post. I have 2 questions :

    - the System.Transactions in Longhorn. It's all managed code, right? No more COM interop.
    - using this System.Transactions i can use transactions for anything..for instance...let's say i have a web service which calls some business procedure. The BLL modifies a local db, then it calls a singletone remoting objects which modifies another database and after that i finally call yet another web services which modifies yet another database. Can i make this as s single those transactionable operation ?

    Cheers and thanks for the info.

  • Anonymous
    March 05, 2004
    You've been Taken Out. Thanks for the Good Post!

  • Anonymous
    March 25, 2004
    The comment has been removed

  • Anonymous
    April 07, 2004
    Hi,

    I still do not understand it. I have some problems regarding MSDTC on a cluster of Windows 2003 and SQL 2000. The application that connects to the database is using MSDTC and it is working fine (when I test it with WinRM0820 and DTCPING) from the one node of the cluster to the other node of the cluster, but from a different machine (not a cluster member) it is not working.
    It seems to be something with rights on file or registry, but I can not get hold on to it.
    What does the MSDTCPRX.DLL do? And where should it be registred?

    Thanks in advance

  • Anonymous
    April 10, 2004
    And what about those firewall pop ups saying "application msdtc.* is trying to act as a server" ??? should I be worried about that?

  • Anonymous
    April 13, 2004
    Gheorghe,
    Thanks for the nice words. To answer your questions:

    1. In most of the cases System.Transactions will use only managed code. In the same time, it is possible that there will be parts in System.Transactions that will use COM Interop (for instance when talking to MSDTC using Oletx protocol). If performance is your concern, than you need to be aware that the price paid for going cross-process or cross-machine or writing to the disk (that happen when Oletx protocol is used) is considerably higher than the usage of COM Interop.

    2. We do our best to enable the scenario you are describing. When you put web services into the picture, Indigo will be the one that will smoothly enable the flow of the transaction between web services. Without Indigo, you can still flow transactions between web services but you have to take care of all the work. Also, without Indigo, you will lack the firewall friendliness of WS-Atomic Transactions.

  • Anonymous
    April 13, 2004
    Gé Brander,

    I recommend that you post your issue, with more details (for instance what action are you trying to do and how it fails, what error do you get?) to http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.platformsdk.complus_mts&lang=en&cr=US .

    Msdtcprx.dll is "the interface" you use to talk to MSDTC service to create, enlist, commit or abort transactions. You don't have to register it, it comes with the OS.

  • Anonymous
    April 13, 2004
    Emilio,

    Msdtc is a "server" by definition. If you don't use distributed transactions you can disable them on XP or W2K3 and those firewall pop-ups should go away.

  • Anonymous
    May 10, 2004
    The comment has been removed

  • Anonymous
    May 11, 2004
    Sunil,

    Standalone MSDTC on a cluster machine is not supported. MSDTC needs to be a cluster resource.

  • Anonymous
    April 20, 2005
    Hi Florin.. MSDTC looks good, but what about the transaction co-ordination that we can implement within the SQL server (using "begin transaction" and "commit transaction" within the stored procedures, for example). What advantages does MSDTC provide over that?
    Thank you..

  • Anonymous
    April 20, 2005
    Rama,

    MSDTC is about distributed transactions that span around multiple resource managers that can exist in a local or remote location.

    If you are using only one database, and your work is limited to a stored procedure than you probably don't need MSDTC.

    With System.Transactions in Whidbey, we are putting in a place a mechanism called promotion that will allow you to use transactions with no "penalty" and to "pay for play" for each additional resource that you add to the transaction. The performance for System.Transaction using only one database that supports "promotable transactions" (Microsoft SQL Server 2005 does) is similar to using ADO.NET one database transaction operations.

  • Anonymous
    September 16, 2005
    PDC05
    The other day I mentioned some of the issues surrounding the appropriate scenarios for atomic...

  • Anonymous
    February 01, 2006
    The comment has been removed

  • Anonymous
    February 01, 2006
    To: Kurt
    Thanks for your feedback. Would you be able to share why do you think so? We are open to improve MSDTC.

  • Anonymous
    February 03, 2006
    I'm setting up a Win2003 cluster with SQL 2005 failover clustering. Microsoft recommends running MSDTC in a separate cluster group with its own name, ip, and disk resources. How large should my physical disk resource be for this MSDTC cluster group?

  • Anonymous
    February 03, 2006
    To: Sam
    MSDTC will store its log file on the physical disk in the cluster. By default, the size of the log file is 4MB. So, your disk size should be at least your log file size.

  • Anonymous
    February 22, 2006
    It probably should be installed but not active by default, and set to automatically start when an application requiring it's functionality is installed.

    This would reduce overheads and the security concerns of those who don't use it.

  • Anonymous
    February 22, 2006
    To: Peter Manser

    On client machines (XP or Vista), the service is not started by default. It will demand-start when an application will try to use transactions.

  • Anonymous
    March 10, 2006
    I am a bit confused. When we setup our MS & SQL Cluster we decided that we didn't need MS DTC. Now we are getting ready to install SP1 and from the docs it sounds like we absolutely need to install and configure this service. Is this true?? Our cluster is ONLY for Failover, not Load Balancing.  Please advise.

  • Anonymous
    March 16, 2006
    I have been facing a problem with my Business (COM) object hosted on Application server(windows 2003) in COM+ with transaction set as required new. The COM internally calls DB objects which have a function to update MS SQL database table(using Stored Proc) on a different machine(Windows 2003 cluster).

    Network DTC is enabled on both machines and MSDTC is configured on windows cluster as well.

    Fetch and insert work fine only problem with updates.

    Some times the update works fine and some times it throws a SQL time out error.
    Could anyone help me in troubleshooting this.

    Thanks in advance..

  • Anonymous
    March 16, 2006
    To: Aileen

    Yes, on W2K3 cluster, the MSDTC needs to be a clustered resource if you or any app needs to use it for transactions. MS SQL Server is using MSDTC transactions.

  • Anonymous
    March 27, 2006
    The comment has been removed

  • Anonymous
    May 03, 2006
    The comment has been removed

  • Anonymous
    June 23, 2006
    PingBack from http://zainal.wordpress.com/2006/06/24/http11-500-server-error/

  • Anonymous
    October 03, 2006
    To: Kwan There is a known issue with SP1 Web Edition for Server 2003. To workaround the issue, you can run the following commands: reg add "HKLMsoftwaremicrosoftwindows ntcurrentversioncluster server" reg add "HKLMsoftwaremicrosoftwindows ntcurrentversioncluster server" /v ClusterInstallationState /d 1 /t REG_DWORD

  • Anonymous
    October 03, 2006
    To: Mark Minasi If you are referring to http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=419544&SiteID=1 then the answer is that currently MSDTC has no effect on Active Directory (yet). The security settings for MSDTC are different depending on the fact that the machine is a DC or not (tigher settings on DC). When a machine is promoted/demoted to/from a DC, the AD is sending a notification to MSDTC. When MSDTC is trying to change its config, it fails due to a permission bug.

  • Anonymous
    May 30, 2008
    Hello i am a entry level enterprise developer , so please bare with my ignorance. Currently we have a com+ application ( Factelligence  , used widely in the manufacturing industry) . It has certain API's to create inventory etc .  and we will be writing our own libraries to work along side of Factelligence. Am i right to assume that any database calls made by the Factelligence API will go through the MSDTC ? . i am not really concerned about multiple databases but more about reliable transaction control. I appreciate your help.

  • Anonymous
    May 30, 2008
    To: arunr14 COM+ uses MSDTC

  • Anonymous
    May 30, 2008
    Thank you for your reply. Following up on my previous comment ,Is it possible   to combine the Transaction created by the COM+ application and my custom commands into one before sending it to the database?

  • Anonymous
    May 30, 2008
    To: arunr14 Yes, you can combine the trasaction that COM+ is using with other transacted work. I do recommend posting at the Transactions Forum http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=388&SiteID=1

  • Anonymous
    August 24, 2008
    The comment has been removed