进行批量加载时断言检查失败
Assertion check failed when doing bulk loading
根据 https://docs.microsoft.com/en-us/sql/relational-databases/indexes/columnstore-indexes-data-loading-guidance?view=sql-server-2017,我们正在对列存储索引的批量加载操作进行一些优化,每当我们尝试插入 CCI 时,我们都会得到以下信息:
Location: columnset.cpp:3707
Expression: !pColBinding->IsLobAccessor()
SPID: 55
Process ID: 1988
Msg 3624, Level 20, State 1, Line 3
A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software bug or data corruption. To check for database corruption, consider running DBCC CHECKDB. If you agreed to send dumps to Microsoft during setup, a mini dump will be sent to Microsoft. An update might be available from Microsoft in the latest Service Pack or in a Hotfix from Technical Support.
Msg 596, Level 21, State 1, Line 0
Cannot continue the execution because the session is in the kill state.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
没有数据损坏--DBCC CHECKDB 运行没有错误。插入少量行成功,但是当我们尝试超过 1000 行时它失败了(我们没有试图找出发生失败的确切数字,但我们也尝试过超过一百万)。我们是 运行 SQL Server 2017, 14.0.3223.3.
如何重现问题:
第 1 步:创建示例暂存 table
CREATE TABLE [dbo].[Data](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Description] [varchar](50) NOT NULL,
[JSON] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_Data] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[Data] WITH CHECK ADD CONSTRAINT [CK_Data] CHECK ((isjson([JSON])=(1)))
GO
ALTER TABLE [dbo].[Data] CHECK CONSTRAINT [CK_Data]
GO
第 2 步:用示例数据填充暂存 table(我们的 JSON 列超过 100KB)
DECLARE @i INT = 1
WHILE (@i < 1000)
BEGIN
INSERT INTO Data
SELECT 'Test' AS Description, BulkColumn as JSON
FROM OPENROWSET (BULK 'C:\Temp\JSON.json', SINGLE_CLOB) AS J
SET @i = @i + 1
END
第 3 步:创建示例目标 table 和 CCI
CREATE TABLE [dbo].[DataCCI](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Description] [varchar](50) NOT NULL,
[JSON] [nvarchar](max) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[DataCCI] WITH CHECK ADD CONSTRAINT [CK_DataCCI] CHECK ((isjson([JSON])=(1)))
GO
ALTER TABLE [dbo].[DataCCI] CHECK CONSTRAINT [CK_DataCCI]
GO
CREATE CLUSTERED COLUMNSTORE INDEX [cci] ON [dbo].[DataCCI] WITH (DROP_EXISTING = OFF, COMPRESSION_DELAY = 0) ON [PRIMARY]
GO
第 4 步:从样本暂存到 CCI 的批量加载
INSERT INTO DataCCI WITH (TABLOCK)
SELECT Description, JSON FROM Data
我错过了什么?有更好的方法或解决方法吗?
谢谢。
我能够通过从目标 table 中删除约束来解决这个问题。
干杯!
根据 https://docs.microsoft.com/en-us/sql/relational-databases/indexes/columnstore-indexes-data-loading-guidance?view=sql-server-2017,我们正在对列存储索引的批量加载操作进行一些优化,每当我们尝试插入 CCI 时,我们都会得到以下信息:
Location: columnset.cpp:3707
Expression: !pColBinding->IsLobAccessor()
SPID: 55
Process ID: 1988
Msg 3624, Level 20, State 1, Line 3
A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software bug or data corruption. To check for database corruption, consider running DBCC CHECKDB. If you agreed to send dumps to Microsoft during setup, a mini dump will be sent to Microsoft. An update might be available from Microsoft in the latest Service Pack or in a Hotfix from Technical Support.
Msg 596, Level 21, State 1, Line 0
Cannot continue the execution because the session is in the kill state.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
没有数据损坏--DBCC CHECKDB 运行没有错误。插入少量行成功,但是当我们尝试超过 1000 行时它失败了(我们没有试图找出发生失败的确切数字,但我们也尝试过超过一百万)。我们是 运行 SQL Server 2017, 14.0.3223.3.
如何重现问题:
第 1 步:创建示例暂存 table
CREATE TABLE [dbo].[Data](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Description] [varchar](50) NOT NULL,
[JSON] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_Data] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[Data] WITH CHECK ADD CONSTRAINT [CK_Data] CHECK ((isjson([JSON])=(1)))
GO
ALTER TABLE [dbo].[Data] CHECK CONSTRAINT [CK_Data]
GO
第 2 步:用示例数据填充暂存 table(我们的 JSON 列超过 100KB)
DECLARE @i INT = 1
WHILE (@i < 1000)
BEGIN
INSERT INTO Data
SELECT 'Test' AS Description, BulkColumn as JSON
FROM OPENROWSET (BULK 'C:\Temp\JSON.json', SINGLE_CLOB) AS J
SET @i = @i + 1
END
第 3 步:创建示例目标 table 和 CCI
CREATE TABLE [dbo].[DataCCI](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Description] [varchar](50) NOT NULL,
[JSON] [nvarchar](max) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[DataCCI] WITH CHECK ADD CONSTRAINT [CK_DataCCI] CHECK ((isjson([JSON])=(1)))
GO
ALTER TABLE [dbo].[DataCCI] CHECK CONSTRAINT [CK_DataCCI]
GO
CREATE CLUSTERED COLUMNSTORE INDEX [cci] ON [dbo].[DataCCI] WITH (DROP_EXISTING = OFF, COMPRESSION_DELAY = 0) ON [PRIMARY]
GO
第 4 步:从样本暂存到 CCI 的批量加载
INSERT INTO DataCCI WITH (TABLOCK)
SELECT Description, JSON FROM Data
我错过了什么?有更好的方法或解决方法吗?
谢谢。
我能够通过从目标 table 中删除约束来解决这个问题。
干杯!