Create the simplest database possible:
CREATE DATABASE DatabaseCheck
Add this database to an Availability Group, where secondary is not readable
On primary run:
DBCC CHECKDB ('DatabaseCheck') WITH EXTENDED_LOGICAL_CHECKS
It succeeds:
CHECKDB found 0 allocation errors and 0 consistency errors in database 'DatabaseCheck'. DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Run the same DBCC command on secondary. It fails even though no errors were found:
CHECKDB found 0 allocation errors and 0 consistency errors in database 'DatabaseCheck'. Msg 0, Level 11, State 0, Line 1 A severe error occurred on the current command. The results, if any, should be discarded.
- Removing WITH
EXTENDED_LOGICAL_CHECKS
makes the error go away - Making the secondary replica readable makes the error go away
- Doing a failover and checking the new primary makes the error go away. Checking the new secondary shows the error again.
Any idea what is this about? Checking DBCC CHECKDB documentation doesn't say anything about EXTENDED_LOGICAL_CHECKS being unsupported on non-readable secondary replica. Looks like a bug in the command itself to me.
One thing I noticed in the command output is that it checks statistics like here:
Verified integrity of statistics 'sys.sysrscols.clst'. Verified integrity of statistics 'sys.sysrowsets.clust'. Verified integrity of statistics 'sys.sysrowsets._WA_Sys_00000002_00000005'. Verified integrity of statistics 'sys.sysrowsets._WA_Sys_00000003_00000005'. Verified integrity of statistics 'sys.sysrowsets._WA_Sys_00000006_00000005'. Verified integrity of statistics 'sys.sysrowsets._WA_Sys_00000004_00000005'. Verified integrity of statistics 'sys.sysrowsets._WA_Sys_00000005_00000005'. Verified integrity of statistics 'sys.sysrowsets._WA_Sys_00000008_00000005'.
These are absent when run on secondary
Reproduced on:
Microsoft SQL Server 2019 (RTM-CU23) (KB5030333) - 15.0.4335.1 (X64) Sep 21 2023 17:28:44 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: )
Edit:
The only message in error log is this:
DBCC CHECKDB (DatabaseCheck) executed by Domain\user found 0 errors and repaired 0 errors. Elapsed time: 0 hours 0 minutes 0 seconds. Internal database snapshot has split point LSN = 00000034:000001b1:0001 and first LSN = 00000034:000001af:0002.
There are no recent dumps in sys.dm_server_memory_dumps
SELECT * FROM sys.dm_server_memory_dumps ORDER BY creation_time DESC;
and see if there is a relevant memory dump. This is almost certainly a bug in AG.