Troubleshooting Guide: SQL Server Error 3982
Why This Error Happens
Error 3982 occurs when a session attempts to start a new local or distributed transaction while an existing transaction—managed either by the Microsoft Distributed Transaction Coordinator (MSDTC) or a bound session—is still active and has not been committed or rolled back. This typically happens due to improperly closed application connections, a misconfigured MSDTC service that fails to clean up orphaned transactions, or application code that attempts to nest incompatible transaction types (e.g., mixing BEGIN DISTRIBUTED TRANSACTION with an active local transaction). In Windows Server 2025 environments, this is often exacerbated by stricter security defaults requiring explicit DTC network access configuration.
Step-by-Step Resolution Guide
Step 1: Verify and Restart the MSDTC Service
- Open Services.msc on the Windows Server 2025/Windows 11 machine.
- Locate Distributed Transaction Coordinator, right-click, and select Restart.
- Alternatively, use PowerShell:
Restart-Service -Name MSDTC -Force - This clears any “stuck” transaction states that are blocking new sessions.
Step 2: Check Active Transactions in SQL Server
- Open SQL Server Management Studio (SSMS) and run the following query to identify blocking sessions:
DBCC OPENTRAN;
SELECT * FROM sys.dm_tran_active_transactions;
- Identify the
transaction_idand associatedsession_idthat is holding the lock. - Kill the offending session using
KILL [session_id]if it is safe to do so.
Step 3: Reconfigure MSDTC Security Settings
- Navigate to Component Services (
dcomcnfg.exe) > Computers > My Computer > Distributed Transaction Coordinator > Local DTC. - Right-click Local DTC and select Properties, then go to the Security tab.
- Ensure Network DTC Access, Allow Inbound/Outbound, and Enable XA Transactions (if applicable) are checked.
- Click OK and restart the MSDTC service to apply the new security context.
Step 4: Audit Application Transaction Logic
- Review the application code (e.g., .NET
TransactionScopeor JDBC connections) to ensure transactions are explicitly committed or rolled back in afinallyblock. - Ensure connection pooling settings are not reusing a connection that still has an enlisted transaction from a previous request.
- Verify that
SET XACT_ABORT ONis used in stored procedures to ensure transactions are rolled back immediately upon error.
Alternative or Verification Steps
- Verification: After restarting the DTC service, run
Get-Service MSDTCin PowerShell to confirm the status is “Running,” then attempt the failed transaction again to ensure Error 3982 no longer appears. - Alternative: If the error persists specifically in a clustered environment, verify that the MSDTC resource is online in Failover Cluster Manager and is not pointing to a corrupted CLB (Clustered Log Base) resource, which may require recreating the DTC resource group entirely.