Troubleshooting Guide: SQL Server Error 8540 — Distributed Transaction Forced to Roll Back
Why This Error Happens
Error 8540 occurs when the Microsoft Distributed Transaction Coordinator (MS DTC) loses communication with one or more participants in a distributed transaction, causing the Unit of Work (UOW) to be forcibly rolled back. This is typically caused by the DTC service being stopped or misconfigured, network/firewall rules blocking DTC traffic between servers, or mismatched DTC security settings (such as “No Authentication Required” vs “Mutual Authentication”) between the linked servers. Corrupted MSDTC logs or orphaned transactions in the DTC transaction list can also trigger this failure.
Step-by-Step Resolution Guide
Step 1: Verify and Restart the MSDTC Service
- Open Services.msc on both the local and remote SQL Server instances.
- Locate Distributed Transaction Coordinator, ensure the Startup Type is set to Automatic.
- Right-click and select Restart to clear any stuck transaction states.
- Alternatively, run in an elevated Command Prompt:
net stop msdtc && net start msdtc.
Step 2: Reconfigure DTC Security Settings
- Open Component Services (
dcomcnfg.exe) → Computers → My Computer → Distributed Transaction Coordinator → Local DTC. - Right-click Local DTC → Properties → Security tab.
- Enable Network DTC Access, check Allow Inbound and Allow Outbound.
- Set Transaction Manager Communication to Mutual Authentication Required (or No Authentication Required only if servers are not domain-joined).
- Apply changes; this will automatically restart the MSDTC service.
Step 3: Check Firewall and Port Configuration
- Ensure Windows Defender Firewall allows the “Distributed Transaction Coordinator” rule (inbound/outbound) on both servers.
- Verify TCP port 135 (RPC Endpoint Mapper) is open between the SQL Server and the remote resource manager.
- If using a custom RPC port range, confirm it is open in Windows Server 2025’s firewall:
New-NetFirewallRule -DisplayName "MSDTC RPC" -Direction Inbound -Protocol TCP -LocalPort 135 -Action Allow
Step 4: Validate Linked Server and Transaction Settings
- In SQL Server Management Studio (SSMS), go to Server Objects → Linked Servers → [Your Linked Server] → Properties.
- Under Server Options, confirm RPC and RPC Out are set to True if the linked server participates in distributed transactions.
- Confirm the linked server login mapping uses an account with sufficient permissions on the remote instance.
Step 5: Clear Orphaned Transactions
- Open Component Services → Distributed Transaction Coordinator → Local DTC → Transaction List.
- Identify any transactions stuck in a “Pending” or “Aborting” state.
- Right-click and manually resolve (commit or abort) stale transactions, then restart MSDTC once more to fully clear the queue.
Alternative or Verification Steps
- Run
DTCPing.exebetween the two servers (available via Microsoft Diagnostics Tools) to confirm successful two-way DTC communication before retrying the transaction. - If the error persists after configuration changes, check the MSDTC event logs (Event Viewer → Applications and Services Logs → Microsoft → Windows → MSDTC) for RPC or authentication failures pointing to a specific unreachable participant.