Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is MSDTC not supported when using SQL Server Mirroring & Automatic Failover?

I have an application that I would like to have support SQL Server Mirroring. However, the architecture is currently such that multiple WCF services and DB connections will be enlisted in a single MSDTC transactions, and Microsoft states that MSDTC is not supported when using Mirroring.

Their explanation is not terribly informative:

A similar scenario can occur when you use database mirroring with MS DTC transactions. For example, the new principal server contacts the MS DTC after a failover. However, the MS DTC has no knowledge of the new principal server. Therefore, the MS DTC stops any transactions that are in the "preparing to commit" phase, even though the transactions are considered committed in other databases.

What I am having a problem understanding is the last sentence. How is this any different than if the DB server was not mirrored, and just died at that same point in time? Can someone explain that to me? I need to be able to explain this to others in my organization (as well as customers), but I don't understand why MSDTC can properly rollback/compensate in one scenario, but it cannot if one of the participants is a mirrored SQL server (in Full Safety mode).

like image 553
Bryan Batchelder Avatar asked Jul 12 '10 19:07

Bryan Batchelder


People also ask

How do I know if MSDTC is enabled?

Go to Administrative Tools -> Component Services. Expand Component Services -> Computers -> Right-click -> Properties -> MSDTC tab. Hit the Security Configuration button.

What is MSDTC SQL Server?

Microsoft Distributed Transaction Coordinator (popularly known as MSDTC) is a coordinator to handle the distributed transactions. A distribution transaction involves two or more databases in a single transaction.


1 Answers

MSDTC is no aware of mirroring. So when it enrolls a resource manager in a distributed transaction it will know that RM by its name, say Server A. After a fail over occurs, the log will tell the new principal 'go contact DTC and see what is the status of transaction T'. The new principal, named Server B, goes to DTC and says 'I am server B, what is the result of transaction T?' and the DTC will tell him 'Go away, I don't know you, you are not enrolled in transaction T'. This is what the KB article describes too:

After a failover, the new principal server cannot connect to the MS DTC of the previous principal server that uses the same resource ID. Therefore, the new principal server cannot obtain the transaction status

You are asking "How is this any different than if the DB server was not mirrored, and just died at that same point in time?". The difference is that if this would had occur, then when the database is recovered it will be recovered on the same server and this server can contact the DTC and ask it to rollback the distributed transaction in which it was enrolled.

like image 56
Remus Rusanu Avatar answered Nov 15 '22 03:11

Remus Rusanu