Troubleshooting Guide: SQL Server Error 3981
“The transaction operation cannot be performed because there are pending requests working on this transaction.”
Why This Error Happens
This error occurs when SQL Server attempts to commit, rollback, or close a transaction while another session, worker thread, or asynchronous request still holds an active reference to it. This is commonly triggered by overlapping Multiple Active Result Sets (MARS) connections, orphaned batches, or a client-side timeout that disconnects before the server-side transaction fully completes. It can also surface when linked server calls or distributed transactions leave residual locks on the transaction context due to network interruption or driver-level connection pooling issues.
Step-by-Step Resolution Guide
Step 1: Identify Blocking Sessions and Pending Requests
- Open SQL Server Management Studio (SSMS) and run the following query to check for active requests tied to the problematic transaction:
SELECT session_id, status, command, wait_type, last_wait_type, transaction_id
FROM sys.dm_exec_requests
WHERE transaction_id = (SELECT transaction_id FROM sys.dm_tran_current_transaction);
- Note any
session_idvalues showingSUSPENDEDorSLEEPINGstatus, as these are likely holding the transaction open.
Step 2: Disable or Audit MARS on the Connection String
- If your application uses Multiple Active Result Sets, inspect the connection string (typically in
web.config,app.config, or ODBC DSN settings underC:\Windows\System32\odbcad32.exe). - Temporarily set
MultipleActiveResultSets=False;to confirm if MARS concurrency is the root cause. - Restart the application pool or service in IIS Manager (
inetmgr.exe) to apply the connection string change.
Step 3: Terminate Orphaned Sessions Safely
- Use the session IDs gathered in Step 1 to safely kill orphaned connections:
KILL <session_id>;
- Avoid killing system session IDs (below 50), as these are reserved for internal SQL Server processes.
Step 4: Update SQL Server Native Client and Drivers
- Navigate to Control Panel > Programs > Programs and Features on Windows Server 2025 / Windows 11.
- Verify that the SQL Server Native Client (or Microsoft ODBC Driver 18+) is updated to the latest build, as older drivers mishandle asynchronous transaction completion signals.
- Reboot the application server after updating to clear cached driver handles.
Step 5: Review Distributed Transaction Coordinator (MSDTC) Settings
- Open
dcomcnfg.exe(Component Services) and navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator. - Ensure Network DTC Access is enabled under Security Configuration, specifically allowing Inbound/Outbound transactions if linked servers are involved.
- Restart the MSDTC service via
services.mscto clear stale transaction locks.
Alternative or Verification Steps
- Re-run the original transaction/stored procedure in isolation using
SET XACT_ABORT ON;at the beginning of the script to ensure immediate rollback on error rather than leaving pending requests. - If the error persists under heavy load, check
sys.dm_os_waiting_tasksforwait_type = 'TRANSACTION_MUTEX', which confirms a concurrency deadlock requiring application-level logic changes to serialize transaction commits.