Troubleshooting Guide: SQL Server Error 6635 – Compressed Showplan XML Stream Corrupted
Why This Error Happens
Error 6635 occurs when SQL Server 2025 attempts to decompress a cached showplan XML stream but encounters invalid or truncated binary data in the plan cache. This typically results from memory pressure causing improper eviction of query plans, corruption in the sys.dm_exec_query_plan internal storage, or a mismatch between the compression codec version used to write the stream and the one used to read it (often seen after an in-place upgrade or cumulative update). In rare cases, this is triggered by faulty RAM or disk-level corruption affecting tempdb, where showplan data is temporarily staged during execution.
Step-by-Step Resolution Guide
Step 1: Clear the Plan Cache to Remove Corrupted Entries
- Run
DBCC FREEPROCCACHEto flush all cached execution plans immediately. - For a targeted fix, identify the specific plan handle using
SELECT * FROM sys.dm_exec_cached_plans WHERE cacheobjtype = 'Compiled Plan'and remove it withDBCC FREEPROCCACHE (plan_handle). - Restart the SQL Server service via
services.mscornet stop MSSQLSERVER && net start MSSQLSERVERif the corruption persists after cache clearing.
Step 2: Verify and Repair TempDB Integrity
- Since showplan XML is often staged in tempdb during query compilation, run
DBCC CHECKDB (tempdb) WITH NO_INFOMSGS, ALL_ERRORMSGSto check for underlying corruption. - If tempdb files show corruption, stop the SQL Server service, delete the tempdb data/log files (located by default at
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\), and restart the service to force tempdb recreation. - Confirm Windows Server 2025 Storage Spaces or disk health using
Get-PhysicalDisk | Get-StorageReliabilityCounterto rule out hardware-level corruption.
Step 3: Apply the Latest Cumulative Update for SQL Server 2025
- Check your current build number with
SELECT @@VERSION;and compare it against the latest Cumulative Update (CU) listed on the Microsoft Update Catalog. - Download and install the newest CU, as this error has known fixes related to the showplan compression codec in early SQL Server 2025 builds.
- Reboot the Windows Server 2025 host after installation to ensure the
sqlservr.exebinaries and compression DLLs (qds.dll) are fully refreshed.
Step 4: Disable Query Store Temporarily (If Applicable)
- If the error correlates with Query Store plan retrieval, run
ALTER DATABASE [YourDB] SET QUERY_STORE = OFF;to isolate the issue. - Re-enable it afterward with
ALTER DATABASE [YourDB] SET QUERY_STORE = ON (OPERATION_MODE = READ_WRITE);once the cache has been rebuilt cleanly.
Alternative or Verification Steps
- To verify the fix, re-run the query that previously triggered Error 6635 and confirm the actual execution plan renders correctly in SQL Server Management Studio (SSMS) without an XML parsing error.
- If the issue persists after cache clearing and patching, run
DBCC CHECKDBon the user database itself and restore from the last known good backup, as the corruption may extend beyond the plan cache into the database’s execution metadata.