Per https://learn.microsoft.com/en-us/sql/relational-databases/indexes/columnstore-indexes-data-loading-guidance?view=sql-server-2017, we're making some optimizations for a bulk load operation for a columnstore index and, whenever we attempt the insert into the CCI, we get the following:
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.
There is no data corruption--DBCC CHECKDB runs without errors. Inserting a small number of rows succeeds, but it fails when we try over 1000 (we haven't tried to figure out the exact number where failure occurs, but we also tried over a million). We are running SQL Server 2017, 14.0.3223.3.
How to reproduce the problem:
Step 1: Create a sample staging 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
Step 2: Fill the staging table with sample data (our JSON column is over 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
Step 3: Create a sample target table and 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
Step 4: Bulk load from sample staging to CCI
INSERT INTO DataCCI WITH (TABLOCK)
SELECT Description, JSON FROM Data
What am I missing? Is there a better way to do this or a workaround?
Thank you.
I was able to workaround this issue by removing the constraints from the target table.
Cheers!