Troubleshooting Guide: Error 3958 — Transaction Aborted Accessing Versioned Row
Why This Error Happens
Error 3958 occurs when Row Versioning (used by Snapshot Isolation or Read Committed Snapshot Isolation) cannot locate a required version of a row in the version store within tempdb. This typically happens because tempdb has run out of space and was forced to shrink or clean up version store data prematurely, or because the version store cleanup process removed rows still needed by a long-running transaction. Insufficient tempdb sizing, long-running open transactions, or aggressive autogrowth limitations are the most common root causes.
Step-by-Step Resolution Guide
Step 1: Verify Tempdb Space and Configuration
- Open SQL Server Management Studio (SSMS) and connect to the instance.
- Run
EXEC sp_helpdb tempdb;to check current file sizes and growth settings. - Confirm tempdb data files are not set to a restrictive maximum size (MAXSIZE should ideally be set to “Unlimited” or a sufficiently large value).
- Check physical disk space on the drive hosting tempdb files (commonly
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\).
Step 2: Identify Long-Running or Orphaned Transactions
- Run the following query to find transactions holding open the version store:
SELECT * FROM sys.dm_tran_active_snapshot_database_transactions;
- Look for transactions with a high
elapsed_time_secondsvalue or a lowtransaction_sequence_numthat is blocking version store cleanup. - Kill or commit any stale sessions using
KILL <session_id>;if they are confirmed to be orphaned or stuck.
Step 3: Resize and Optimize Tempdb Files
- Increase the initial size of tempdb data files to prevent constant autogrowth events, which fragment disk space and slow down version store writes.
- Navigate to SSMS > Databases > System Databases > tempdb > Properties > Files.
- Set the Initial Size to a value based on your workload (e.g., 10240 MB) and set Autogrowth to a fixed MB increment (e.g., 1024 MB) rather than a percentage.
- Restart the SQL Server service via
services.mscon Windows Server 2025 for file size changes to take full effect if files were not already pre-sized.
Step 4: Move Tempdb to Faster/Larger Storage
- If the current drive lacks sufficient space, move tempdb to a dedicated SSD volume with ample free space using the following T-SQL:
ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = 'D:\SQLTemp\tempdb.mdf');
- Restart the SQL Server (MSSQLSERVER) service for the path change to take effect.
- Ensure the new drive has at least 2-3x the estimated workload requirement in free space.
Alternative or Verification Steps
- To verify the fix, re-run the workload or query that triggered Error 3958 while monitoring
sys.dm_db_file_space_usageto ensure the version store is not consuming 100% of available tempdb space. - If the error persists despite available space, check for Windows Server 2025 disk-level issues (such as Storage Spaces throttling) using the Resource Monitor or Perfmon counter
% Disk Timeon the tempdb volume.