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

Troubleshooting Guide: Error 12407 – Query Store Manager Global Instance Not Available

Why This Error Happens

Error 12407 occurs when the SQL Server Query Store subsystem fails to initialize its global manager instance during database startup or recovery, typically because the internal metadata catalog views (sys.query_store_*) have become corrupted or are out of sync with the database’s internal state. This can also happen if the database was upgraded from an older compatibility level and the Query Store internal storage schema wasn’t fully migrated, or if the MDF/LDF files experienced an unexpected shutdown while Query Store was actively flushing data to disk. In some cases, insufficient memory allocation within the internal SQL Server resource pool prevents the Query Store manager from being instantiated for that database context.

Step-by-Step Resolution Guide

Step 1: Verify Query Store Status and Database Health

  • Open SQL Server Management Studio (SSMS) and connect to the instance reporting the error.
  • Run SELECT name, is_query_store_on FROM sys.databases WHERE name = 'YourDatabaseName'; to confirm current state.
  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to rule out underlying corruption in the data files.

Step 2: Disable and Re-enable Query Store

  • Run ALTER DATABASE YourDatabaseName SET QUERY_STORE = OFF; to force the manager to release its current (broken) state.
  • Wait approximately 30 seconds for the internal cleanup thread to clear cached metadata.
  • Re-enable it with ALTER DATABASE YourDatabaseName SET QUERY_STORE = ON (OPERATION_MODE = READ_WRITE);

Step 3: Clear Query Store Internal Storage

  • If Step 2 fails, run ALTER DATABASE YourDatabaseName SET QUERY_STORE CLEAR; to purge potentially corrupted internal tables.
  • Note: this action is destructive to historical query performance data, so export any critical reports first via sys.query_store_runtime_stats if accessible.
  • Restart the SQL Server service via Services.msc or net stop MSSQLSERVER && net start MSSQLSERVER on Windows Server 2025.

Step 4: Check Resource Governor and Memory Allocation

  • Navigate to Server Properties > Memory in SSMS and confirm “Minimum server memory” is not set higher than available physical RAM.
  • Run sp_configure 'show advanced options', 1; RECONFIGURE; sp_configure 'min server memory'; to validate configuration values.
  • Adjust values if the instance is memory-starved, as Query Store requires a dedicated memory grant to initialize its manager object.

Step 5: Apply Latest Cumulative Update

  • Check your current build with SELECT @@VERSION;.
  • Download and install the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog, as this error has known fixes in early post-RTM patches.
  • Reboot the Windows Server 2025 host after patching to ensure all binaries are correctly swapped.

Alternative or Verification Steps

  • To verify the fix, run SELECT * FROM sys.database_query_store_options; — a successful query returning configuration rows (rather than an error) confirms the manager is now active.
  • If the issue persists after all steps, consider detaching and re-attaching the database (sp_detach_db / sp_attach_db) to force a full re-initialization of all internal subsystems, including Query Store.