Troubleshooting Guide: SQL Server Error 5572 — FILESTREAM Filesystem Corruption
Why This Error Happens
Error 5572 occurs when the SQL Server Database Engine detects an inconsistency between its internal metadata and the actual state of the FILESTREAM data container on the NTFS filesystem. This is commonly caused by an improper shutdown, antivirus or backup software locking/modifying files in the FILESTREAM data directory, or underlying disk/storage corruption. It can also surface if NTFS permissions on the FILESTREAM container were altered outside of SQL Server’s control, breaking the link between the database engine and the file garbage collector.
Step-by-Step Resolution Guide
Step 1: Isolate the Database and Check Storage Health
- Set the affected database to single-user or restricted-user mode to prevent further writes:
ALTER DATABASE [YourDB] SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE; - Run
chkdsk D:\FILESTREAM_Volume /f /r(replace with your actual volume) to rule out physical disk-level corruption on Windows Server 2025/Windows 11. - Check Windows Event Viewer under Windows Logs > System for related NTFS or disk-driver errors (Event ID 7 or 55).
Step 2: Exclude FILESTREAM Directories from Antivirus and Backup Agents
- Navigate to the FILESTREAM data container path (commonly
C:\SQLData\FILESTREAM\) and add it as an exclusion in Windows Defender or any third-party AV via Windows Security > Virus & threat protection > Exclusions. - Ensure third-party backup agents (e.g., VSS-based tools) are not actively snapshotting or locking files in this directory during SQL Server operation.
- Restart the SQL Server service after applying exclusions:
Restart-Service -Name MSSQLSERVER.
Step 3: Run DBCC CHECKFILEGROUP and CHECKDB
- Execute
DBCC CHECKFILEGROUP ('FileStreamGroupName') WITH ALL_ERRORMSGS;to validate the FILESTREAM filegroup specifically. - Follow up with
DBCC CHECKDB ('YourDB') WITH DATA_PURITY, ALL_ERRORMSGS;to scan for broader structural corruption. - Review the output for orphaned FILESTREAM pointers; note any file GUID mismatches reported.
Step 4: Repair or Rebuild the FILESTREAM Container
- If corruption is confirmed and isolated to FILESTREAM data (not metadata), restore the affected filegroup from your most recent clean backup:
RESTORE DATABASE [YourDB] FILE = 'FileStreamLogicalName' FROM DISK = 'E:\Backups\YourDB.bak' WITH NORECOVERY; - If no backup is viable, remove and recreate the FILESTREAM filegroup container, then re-import data from an application-level source if available.
- Verify NTFS permissions on the container grant the SQL Server service account (e.g.,
NT SERVICE\MSSQLSERVER) Full Control.
Step 5: Return Database to Multi-User Mode
- Once validated, switch the database back:
ALTER DATABASE [YourDB] SET MULTI_USER; - Monitor the SQL Server Error Log for recurrence of Error 5572 over the next 24-48 hours.
Alternative or Verification Steps
- Confirm the fix by running
DBCC CHECKFILEGROUPagain — a clean pass with zero allocation or consistency errors confirms resolution. - If the error persists after repair attempts, perform a full
RESTORE DATABASEfrom the last known-good full backup plus transaction logs, as FILESTREAM corruption at the NTFS level often cannot be repaired in-place without data loss.