Troubleshooting Guide: SQL Server Error 8915 — Mismatched Mixed Extent Count
Why This Error Happens
Error 8915 occurs when the SQL Server storage engine detects that the actual number of mixed extents allocated to a database file does not match the count recorded in the file’s header (PFS/GAM page metadata). This mismatch is typically caused by physical disk corruption, improper shutdowns, storage subsystem failures (SAN/RAID controller issues), or interrupted write operations during a crash. It is a DBCC CHECKDB-reported allocation-level consistency error indicating the database’s internal bookkeeping is out of sync with the actual page allocations on disk.
Step-by-Step Resolution Guide
Step 1: Confirm and Document the Error Scope
- Run
DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;in SSMS to capture the full list of errors, not just 8915. - Note the File ID (%d) and the reported vs. expected extent counts from the error output.
- Check the SQL Server Error Log (
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for correlating I/O or disk warnings (e.g., Event ID 823, 824, 825).
Step 2: Rule Out Underlying Storage Problems
- Open Windows Event Viewer (
eventvwr.msc) and check the System log for Disk, ntfs, or storport errors around the time the corruption appeared. - Run
chkdsk D:\ /f /r(replace D: with the volume hosting your .mdf/.ndf files) during a maintenance window to repair file system-level issues. - If using virtualized or SAN storage, validate the underlying LUN health via your storage vendor’s diagnostic tool before proceeding further.
Step 3: Restore from a Known Good Backup (Preferred Fix)
- Take a tail-log backup if the database is still accessible:
BACKUP LOG YourDatabaseName TO DISK = 'D:\Backups\YourDB_tail.trn'; - Restore the last clean full backup plus subsequent log backups up to the point before corruption:
RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDB_Full.bak' WITH NORECOVERY; - Apply each transaction log backup sequentially using
RESTORE LOG ... WITH NORECOVERY, finishing withWITH RECOVERYon the last one.
Step 4: Run Repair as a Last Resort (If No Valid Backup Exists)
- Set the database to single-user mode:
ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE; - Execute
DBCC CHECKDB('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS;— note this can delete corrupted allocation units. - Revert to multi-user mode:
ALTER DATABASE YourDatabaseName SET MULTI_USER;
Step 5: Re-verify Allocation Integrity
- Re-run
DBCC CHECKDBwithALL_ERRORMSGSto confirm Error 8915 and related errors no longer appear. - Rebuild affected indexes if REPAIRALLOWDATA_LOSS dropped any pages:
ALTER INDEX ALL ON YourTable REBUILD;
Alternative or Verification Steps
- Verify the fix: Run
DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;a final time — a clean run with zero allocation errors confirms resolution. - Alternative approach: If corruption recurs frequently on the same volume, migrate the database files to a new disk/LUN via
ALTER DATABASE ... MODIFY FILEand decommission the suspect storage to rule out recurring hardware failure.