Our product loads data from CSV files into various tables via the .NET System.Data.SqlClient.SqlBulkCopy class. After a successful load, all data older than a certain timestamp is removed from the database. This is done by executing the following command until no rows are deleted:
DELETE TOP (100000) FROM DBO.TBL_DDBB WHERE MeasureDateTime < CAST('2020/04/05 00:00:00' as datetime)
This works fine from tables in RowStore format, but when executing this command on a table with a ColumnStore index we get the following error:
Cannot insert duplicate key row in object 'dbo.deleted_bitmap' with unique index 'tuple_key'. The duplicate key value is (98, 0).The statement has been terminated.
The problem is reproducible on multiple tables in ColumnStore format on this SQL Server machine, but not on other SQL Servers that we have.
I cannot figure out why this happens, and I can't anything on the web mentioning this error. Has anybody seen this before or can anybody tell me how to prevent it?
Version information on the SQL Server used:
Microsoft SQL Server 2016 (SP2-CU12) (KB4536648) - 13.0.5698.0 (X64)
Feb 15 2020 01:47:30 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: ) (Hypervisor)