Troubleshooting Guide: SQL Server Error 2802 – Cachestore Flush Event
Why This Error Happens
This informational event is logged when an administrator or application explicitly executes DBCC FREEPROCCACHE or DBCC FREESYSTEMCACHE, forcing SQL Server to clear cached execution plans from the specified cachestore. While not a critical error, frequent occurrences typically indicate that a third-party monitoring tool, maintenance script, or application is aggressively clearing the plan cache, which can lead to excessive recompilation overhead and CPU spikes. In some cases, memory pressure configurations or poorly designed cache-clearing jobs scheduled via SQL Server Agent are the root trigger.
Step-by-Step Resolution Guide
Step 1: Identify the Source of the DBCC Command
- Query the default trace or Extended Events session to capture who is executing
DBCC FREEPROCCACHE:
SELECT * FROM sys.fn_trace_gettable(
(SELECT TOP 1 path FROM sys.traces WHERE is_default = 1), DEFAULT)
WHERE EventClass = 22; -- DBCC event class
- Check SQL Server Agent Job History in SSMS > SQL Server Agent > Job Activity Monitor for any scheduled jobs running cache-clearing commands.
- Review third-party monitoring tools (e.g., SCOM, SolarWinds) configuration, as some run periodic
DBCC FREESYSTEMCACHE('ALL')as part of “optimization” routines.
Step 2: Audit and Disable Unnecessary Cache-Clearing Scripts
- Open SQL Server Management Studio (SSMS) and navigate to
Program Files > Microsoft SQL Server > MSSQL17.MSSQLSERVER > MSSQL > Logto reviewERRORLOGfor timestamps correlating with Event ID 2802. - Disable or reschedule any Agent Jobs found in Step 1 that call
DBCC FREEPROCCACHEoutside of genuine troubleshooting needs via SQL Server Agent > Jobs > Disable. - If a specific plan is the issue rather than the whole cache, replace blanket cache clears with targeted removal:
DBCC FREEPROCCACHE (plan_handle);
Step 3: Adjust Memory and Plan Cache Configuration
- Open SQL Server Configuration Manager and verify
max server memorysettings under Server Properties > Memory aren’t causing SQL Server to self-trigger cache evictions due to memory pressure. - Check for plan cache bloat using:
SELECT objtype, COUNT(*) AS plan_count, SUM(CAST(size_in_bytes AS BIGINT))/1024/1024 AS size_mb
FROM sys.dm_exec_cached_plans
GROUP BY objtype;
- If bloat is caused by ad-hoc queries, enable
optimize for ad hoc workloadsat the instance level:
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'optimize for ad hoc workloads', 1;
RECONFIGURE;
Step 4: Apply Latest Cumulative Update
- Navigate to Windows Update or the Microsoft Update Catalog to confirm SQL Server 2025 is patched to the latest Cumulative Update (CU), as early builds on Windows Server 2025/Windows 11 have known plan cache telemetry logging bugs.
- Restart the SQL Server (MSSQLSERVER) service via
services.mscafter patching.
Alternative or Verification Steps
- Re-run the Extended Events trace from Step 1 for 24–48 hours after remediation; confirm Event ID 2802 frequency drops to zero or near-zero occurrences in the SQL Server Application Event Log (
eventvwr.msc). - If the issue persists despite disabling external scripts, run
DBCC FREEPROCCACHEmanually once to establish a clean baseline, then monitorsys.dm_exec_query_statsfor abnormal recompilation counts as an alternative diagnostic path.