I’m currently migrating a lot of SQL Server instances onto newer virtual machines. Quite a few of these instances talk to each other via Linked Server for various historical reasons. And a lot of that chat is done via distributed transactions, which means configuring MS Distributed Transaction Coordinator.
So one of the first things I need to do, is check that that DTC is working between the 2 boxes. This is dead simple with official PowerShell module for msdtc. It’s as simple as running Test-Dtc and then working through any errors. So, we just run this:
Test-Dtc -LocalComputerName Source -RemoteComputerName Destination
and as this is a post about fixing something, it won’t suprise you that I’m going to get an error message:
"The OleTx CID on SOURCE and DESTINATION is the same. The CID should be unique to each computer."
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MsDtc\TestDtc.psm1:266 char:13
+ throw ([string]::Format($Strings.SameCids, "OleTx", $Loca ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: ("The OleTx CID ...each computer.":String) [], RuntimeException
+ FullyQualifiedErrorId : "The OleTx CID on SOURCE and DESTINATION is the same. The CID should be uniqu
e to each computer."
But in much more fetching shared of red and yellow, announcing that “The OleTx CID on SOURCE and DESTINATION is the same. The CID should be unique to each computer.”
The cause is really simple to grasp. When the Distributed Transaction Coordinator is installed it registers a GUID to identify it, the theory being a GUID clash should be a vanishingly rare occurance.
That is, until someone’s cloning Virtual Machines. So I have a batch of shiny new VMs that all think they’re the same instance of DTC. That’s not so good. It used to be the accepted fix was to manually remove the the distributed transaction coordinator, clean the registry, restart and then reinstall everything. That sounds like a lot of work to me!
The msdtc module makes it very simple to do, so we’re staring off here:
PS C:\Windows\system32> Get-Dtc | Select-Object *
DtcName : Local
KtmRmEndpointCid : 72c409a9-9c7b-4d24-9e0c-b946a2e5aa4c
OleTxEndpointCid : 3eb9ce34-4d2c-48cf-9ebe-d6e888f9b0ca
Status : Started
UisEndpointCid : c5f16d32-01c9-4b65-be57-4521fa4bb934
VirtualServerName : SOURCE
XAEndpointCid : fcec2fe2-eab2-4277-853a-6ea4d7736430
PSComputerName :
CimClass : root/MsDtc:DtcInstance
CimInstanceProperties : {DtcName, KtmRmEndpointCid, OleTxEndpointCid, Status...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
While DTC normally installs with a default log path, we’ll just make sure and grab it first. Then it’s just as simple as Uninstall-DTC and Install-DTC:
$logPath = (Get-DtcLog).path
Uninstall-Dtc -Confirm:$false
Install-Dtc -LogPath $logPath -StartType AutoStart
And to check it’s worked, lets query dtc and check:
PS C:\Windows\system32> Get-Dtc | Select-Object *
DtcName : Local
KtmRmEndpointCid : 72c409a9-9c7b-4d24-9e0c-b946a2e5aa4c
OleTxEndpointCid : 3eb9ce34-4d2c-48cf-9ebe-d6e888f9b0ca
Status : Started
UisEndpointCid : c5f16d32-01c9-4b65-be57-4521fa4bb934
VirtualServerName : VMCLSTR-IVANTI
XAEndpointCid : fcec2fe2-eab2-4277-853a-6ea4d7736430
PSComputerName :
CimClass : root/MsDtc:DtcInstance
CimInstanceProperties : {DtcName, KtmRmEndpointCid, OleTxEndpointCid, Status...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
And there we have a new unique OleTxEndPointCid and we’re good to go
Leave a Reply