可能是 Microsoft SQL Server 2019 (CTP3.0) 中的错误 DMV sys.dm_db_database_page_allocations 与详细模式报告如下
消息 824,级别 24,状态 2,第 1 行 SQL Server 检测到基于逻辑一致性的 I/O 错误:页面 ID 不正确(预期为 1:457714;实际为 0:0)。它发生在文件“C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\test.mdf”中偏移量 0x000000df7e4000 的数据库 ID 6 中的页面 (1:457714) 读取期间。SQL Server 错误日志或操作系统错误日志中的其他消息可能会提供更多详细信息。这是威胁数据库完整性的严重错误情况,必须立即纠正。完成完整的数据库一致性检查 (DBCC CHECKDB)。这个错误可能是由许多因素引起的;有关详细信息,请参阅 SQL Server 联机丛书。
测试脚本
-- Create table to hold sample data
CREATE TABLE Visits2
(
ID INT,
I100 INT,
I1000 INT,
I10000 INT,
I100000 INT,
I1000000 INT,
I10000000 INT,
IP_Address VARCHAR(15),
VisitDate DATE
);
GO
-- Create Tally Table
GO
CREATE VIEW vw_Tally AS
--Itzik style tally table
WITH lv0 AS (SELECT 0 g UNION ALL SELECT 0)
,lv1 AS (SELECT 0 g FROM lv0 a CROSS JOIN lv0 b) -- 4
,lv2 AS (SELECT 0 g FROM lv1 a CROSS JOIN lv1 b) -- 16
,lv3 AS (SELECT 0 g FROM lv2 a CROSS JOIN lv2 b) -- 256
,lv4 AS (SELECT 0 g FROM lv3 a CROSS JOIN lv3 b) -- 65,536
,lv5 AS (SELECT 0 g FROM lv4 a CROSS JOIN lv4 b) -- 4,294,967,296
,Tally (n) AS
(SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM lv5)
SELECT TOP (1000000) n
FROM Tally
ORDER BY n;
GO
-- Populate Visits2 with sample data
SET NOCOUNT ON;
DECLARE @Max bigint = (select ISNULL(max(ID),0) From Visits2);
WHILE @Max < 60000000 BEGIN
WITH TallyTable AS (
SELECT n + @Max as N,
CAST(RAND(CHECKSUM(NEWID())) * 255 as INT) + 1 AS A4,
CAST(RAND(CHECKSUM(NEWID())) * 255 as INT) + 1 AS A3,
CAST(RAND(CHECKSUM(NEWID())) * 255 as INT) + 1 AS A2,
1.0 + floor(1 * RAND(convert(varbinary, newid()))) AS A1,
DATEADD(DD, 1.0 + floor(62 *
RAND(convert(varbinary, newid()))),'2018-07-01') AS VisitDate
FROM vw_Tally)
INSERT INTO Visits2 (ID, I100, I1000, I10000, I100000,
I1000000, I10000000, IP_Address, VisitDate)
SELECT n,n%100, n%1000, n%10000,n%100000,
n%1000000, n%10000000,
CAST(A1 AS VARCHAR) + '.' + CAST(A2 AS VARCHAR) +
'.' + CAST(A3 AS VARCHAR) +
'.' + CAST(A4 AS VARCHAR), VisitDate
FROM TallyTable
set @Max = (select ISNULL(max(ID),0) From Visits2);
END
打开一个新的查询窗口执行
CREATE INDEX NC_Visits2_1 ON dbo.Visits2 (I100)
WITH (ONLINE = ON,RESUMABLE = ON);
打开第二个窗口执行
ALTER INDEX NC_Visits2_1 ON dbo.Visits2 PAUSE;
打开第三个窗口并执行
SELECT *
FROM sys.dm_db_database_page_allocations
(
DB_ID(),
OBJECT_ID('dbo.Visits2'),
NULL,
NULL,
'detailed'
)
该错误仅在使用 DETAILED 模式时发生。有趣的是,CHECKDB 没有报告任何错误。
还有其他人遇到同样的错误吗?