可能是Microsoft SQL Server 2019(CTP3.0)中的错误
之后的DMV sys.dm_db_database_page_allocations及其“详细模式”报告第824条消息,状态2,第2行,第1行 SQL Server检测到基于逻辑一致性的I / O错误:错误的pageid(预期为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'
)
仅当使用“详细”模式时才会发生错误。有趣的是,CHECKDB不报告任何错误。
还有其他人遇到相同的错误吗?
答案 0 :(得分:0)
我能够在Linux(Ubuntu)上使用CTP 3.1重现这些症状。似乎未记录的sys.dm_db_database_page_allocation
DMV不能正确说明创建过程中处于暂停状态的页面。
您可以在Azure Feedback Forum上报告此错误,以提高意识,但请注意,该错误可能会得到解决,也可能无法得到解决。解决此问题的方法取决于产品团队,因为它是未记录且不受支持的功能(尽管很有用)。