SQL SERVER – Error: 8509 – Import of Microsoft Distributed Transaction Coordinator (MS DTC) transaction failed: 0x8004d00e(XACT_E_NOTRANSACTION)

Have you ever seen an issue related to MS DTC, SQL Server and JDBC XA distributed transactions? A client contacted me for help and he wanted my opinion within one hour. They signed up for my On Demand consulting services and we started looking at the server and application.

They showed me the error in their application which was as below

Caused by: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: Failed to enlist. Error: “Import of Microsoft Distributed Transaction Coordinator (MS DTC) transaction failed: 0x8004d00e(XACT_E_NOTRANSACTION).”
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:647)
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.start(SQLServerXAResource.java:679)
at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.start(WSRdbXaResourceImpl.java:1525)
at com.ibm.ejs.j2c.XATransactionWrapper.start(XATransactionWrapper.java:1475)
at com.ibm.ws.Transaction.JTA.JTAResourceBase.start(JTAResourceBase.java:157)
at com.ibm.tx.jta.impl.RegisteredResources.startRes(RegisteredResources.java:1044)

I asked them to show SQL ERRORLOG to see if there are some DTC related messages.

2017-08-20 09:47:16.76 spid78 Attempting to load library ‘SQLJDBC_XA.dll’ into memory. This is an informational message only. No user action is required.
2017-08-20 09:47:16.77 spid78 Using ‘SQLJDBC_XA.dll’ version ‘0004.00.2206’ to execute extended stored procedure ‘xp_sqljdbc_xa_start’. This is an informational message only; no user action is required.
2017-08-20 09:47:21.45 spid77 Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2017-08-20 09:47:23.95 spid77 Recovery of any in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC) has completed. This is an informational message only. No user action is required.
2017-08-20 09:47:23.96 spid77 Error: 8509, Severity: 16, State: 1.
2017-08-20 09:47:23.96 spid77 Import of Microsoft Distributed Transaction Coordinator (MS DTC) transaction failed: 0x8004d00e(XACT_E_NOTRANSACTION).

Every time we tried XA transaction from application, it caused error 8509 in ERRORLOG.

Here are a few more details about the environment which you may want to match before implementing:

  1. Clustered Instance of SQL Server.
  2. Separate group for MSDTC resource in cluster.

DTC Settings were OK. Below is the checklist

  • Go to “Administrative Tools > Component Services” (or Start > Run > DcomCnfg > Enter)
  • On the left navigation tree, go to “Component Services > Computers > My Computer> Distributed Transaction Coordinator > Clustered DTCs “
  • Right click on the DTC service for this SQL Server group and select “Properties”.
  • Go to the security tab and check “Network DTC Access”, “Allow Inbound”, and “Allow Outbound”.

Since it was a clustered DTC, the next thing which came to my mind was DTC and SQL mapping in the cluster. I looked up at various resources and found the solution.

WORKAROUND/SOLUTION

Here are the three commands I used to fix the mapping.

  1. View the mapping
msdtc -tmmappingview *
  1. Clear the mapping.
msdtc.exe -tmMappingClear -name DTC_INST02_Mapping
  1. Create correct mapping
Msdtc -tmMappingSet -name DTC_INST02_Mapping -service "MSSQL$INST02" -ClusterResourceName "MSDTC-INST02"

Do you need a DTC If you are not using SQL JDBC XA? You do not need to set TM mappings. SQL 2008 Server knows which clustered DTC instance, it needs to use. Since TM mappings are stored in the cluster registry which is shared across all nodes, we can set them at from any of the cluster nodes.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Menu
Exit mobile version