Today I have found 3 production databases writing this message to SQL Server logs :
The Query Store in database XXX has an invalid structure for internal table plan_persist_plan, possibly due to schema or catalog inconsistency.
DBCC CHECKDB runs daily. Today it did not find any inconsistency in all databases. So I executed :
DBCC CHECKTABLE ('sys.plan_persist_plan')
which returns a similar output on all 3 impacted databases :
DBCC results for 'sys.plan_persist_plan'. There are 82193 rows in 1580 pages for object "sys.plan_persist_plan". DBCC execution completed. If DBCC printed error messages, contact your system administrator.
As all seems to be fine, I finish with :
ALTER DATABASE someDB SET QUERY_STORE CLEAR ALL
ALTER DATABASE someDB SET QUERY_STORE (OPERATION_MODE = READ_WRITE)
Query Store is sized 2 to 5 GB, and configured with the very same options on all prod databases.
Does anyone encounter a similar issue ? I see several messages in sys.messages about this :
SELECT *
FROM sys.messages
WHERE text LIKE 'The Query Store%'
AND language_id = 1033