How to fix Error 3931 on Windows Server 2025 / Windows 11

Troubleshooting Guide: Error 3931 in Microsoft SQL Server 2025

Why This Error Happens

Error 3931 occurs when SQL Server detects that the transaction log has been marked as corrupted or the session’s transaction state has become inconsistent, typically due to a failed write to disk, unexpected I/O interruption, or storage subsystem failure during a transaction. This can also happen when a database is forcibly taken offline, experiences a power failure, or when the underlying storage (SAN, virtual disk, or local volume) reports inconsistent sector data mid-transaction. Because the transaction log itself is compromised, SQL Server cannot safely roll back to a savepoint and instead forces a full transaction rollback to preserve database integrity.

Step-by-Step Resolution Guide

Step 1: Verify Storage and I/O Health

  • Check Windows Event Viewer under Windows Logs > System for Disk or NTFS warnings (Event ID 7, 11, or 51) around the same timestamp as Error 3931.
  • Run chkdsk C: /f /r (replace with your actual SQL data/log drive letter) during a maintenance window to detect and repair physical disk errors.
  • Confirm your SAN/virtual disk controller firmware and drivers are up to date, especially on Windows Server 2025 Hyper-V or Storage Spaces Direct configurations.

Step 2: Run DBCC CHECKDB to Identify Corruption

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Execute the following against the impacted database:
DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output for allocation or consistency errors tied to the transaction log or data pages.

Step 3: Repair or Restore the Affected Database

  • If corruption is confirmed, take the database offline and restore from the most recent clean backup:
RESTORE DATABASE [YourDatabaseName] FROM DISK = 'D:\Backups\YourDatabaseName.bak' WITH REPLACE;
  • If no backup is available, attempt a repair as a last resort (data loss risk):
ALTER DATABASE [YourDatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
ALTER DATABASE [YourDatabaseName] SET MULTI_USER;

Step 4: Review Application Transaction Handling

  • Inspect application code for nested transactions using SAVE TRANSACTION combined with long-running or high-latency operations.
  • Ensure explicit BEGIN TRAN / COMMIT TRAN / ROLLBACK TRAN blocks include proper TRY...CATCH error handling to avoid orphaned transactions after Error 3931 triggers.

Alternative or Verification Steps

  • After applying fixes, re-run the failing transaction or stored procedure in SSMS and confirm it commits successfully without triggering Error 3931 again.
  • If the issue persists, check SQL Server error logs (EXEC sp_readerrorlog) for recurring I/O or storage-related warnings, and consider engaging your storage vendor’s diagnostic tools to rule out hardware-level failures.