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

Troubleshooting Guide: SQL Server Error 2515 – “The Page %S_PGID”

Why This Error Happens

Error 2515 occurs when SQL Server’s consistency checker (DBCC) detects that a page reported as belonging to an object does not actually exist in the Page Free Space (PFS) or allocation structures as expected. This is typically caused by database corruption resulting from storage subsystem failures, unexpected server shutdowns, or disk I/O errors that interrupted a write operation. In Windows Server 2025 environments, this can also stem from file system filter driver conflicts (such as third-party antivirus or backup agents) interfering with SQL Server’s direct I/O operations on the MDF/LDF files.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Assess Damage

  • Immediately set the database to single-user mode to prevent further writes: ALTER DATABASE [YourDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run a full diagnostic scan: DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output to identify if the error is isolated to a single table/index or if it indicates systemic corruption across the allocation map.

Step 2: Check Underlying Hardware and Storage Drivers

  • Open Event Viewer on Windows Server 2025 and check the System log for Event ID 153 or 129 (disk timeout errors) which often correlate with SQL error 2515.
  • Verify that the storage controller drivers are updated, specifically if running on Storage Spaces Direct (S2D) or a virtualized disk via Hyper-V.
  • Temporarily disable third-party antivirus scanning on the *.mdf, *.ndf, and *.ldf file extensions to rule out file locking conflicts.

Step 3: Restore From a Known Good Backup

  • Navigate to your backup repository (local disk or Azure Blob Storage) and locate the last verified clean backup.
  • Execute the restore command, ensuring you replace the corrupted file paths:
  • RESTORE DATABASE [YourDB] FROM DISK = 'D:\Backups\YourDB_Full.bak' WITH REPLACE, RECOVERY;
  • If using Always On Availability Groups, consider failing over to a secondary replica instead of a manual restore, provided the secondary passes its own CHECKDB validation.

Step 4: Execute Repair as a Last Resort

  • If no valid backup exists, revert to single-user mode and attempt a repair: DBCC CHECKDB ('YourDB', REPAIR_ALLOW_DATA_LOSS);
  • Be aware this command may deallocate the corrupted pages entirely, resulting in permanent loss of the specific rows involved in the error.
  • Immediately run a full backup after the repair completes to create a new baseline.

Alternative or Verification Steps

  • Verify the fix by setting the database back to multi-user mode (ALTER DATABASE [YourDB] SET MULTI_USER;) and re-running DBCC CHECKDB to confirm zero allocation errors are returned.
  • If corruption recurs frequently, run the Microsoft SQLIOSim utility to stress-test the disk subsystem for underlying hardware faults rather than purely a software/SQL issue.