SqlSyncChangeTrackingProvider using on SQLServer 2019 cause table lock with _bulkdelete procedure
See original GitHub issueHi,
Recently, I test applying Change Tracking of SQL Server 2019 by using SqlSyncChangeTrackingProvider as the document. But _bulkdelete causes table locking and sometimes DMS throws exception ‘Invalid Object … _tracking table’. Here is my case in _bulkdelete procedure: `SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[TopssPartBoFollowUpSync_bulkdelete] @sync_min_timestamp bigint, @sync_scope_id uniqueidentifier, @changeTable [dbo].[TopssPartBoFollowUpSync_BulkType] READONLY AS BEGIN – use a temp table to store the list of PKs that successfully got deleted declare @dms_changed TABLE ([Id] [bigint], PRIMARY KEY ( [Id]));
DECLARE @var_sync_scope_id varbinary(128) = cast(@sync_scope_id as varbinary(128));
;WITH CHANGE_TRACKING_CONTEXT(@var_sync_scope_id), [TopssPartBoFollowUpSync_tracking] AS ( SELECT [p].[Id], CAST([CT].[SYS_CHANGE_CONTEXT] as uniqueidentifier) AS [update_scope_id], [CT].[SYS_CHANGE_VERSION] as [timestamp], CASE WHEN [CT].[SYS_CHANGE_OPERATION] = ‘D’ THEN 1 ELSE 0 END AS [sync_row_is_tombstone] FROM @changeTable AS [p] LEFT JOIN CHANGETABLE(CHANGES [TopssPartBoFollowUpSync], @sync_min_timestamp) AS [CT] ON [p].[Id] = [CT].[Id] ) DELETE [TopssPartBoFollowUpSync] OUTPUT DELETED.[Id] INTO @dms_changed FROM [TopssPartBoFollowUpSync] [base] JOIN [TopssPartBoFollowUpSync_tracking] [changes] ON [changes].[Id] = [base].[Id] WHERE [changes].[timestamp] <= @sync_min_timestamp OR [changes].[timestamp] IS NULL OR [changes].[update_scope_id] = @sync_scope_id;
–Select all ids not inserted / deleted / updated as conflict SELECT [Id] FROM @changeTable [t] WHERE NOT EXISTS ( SELECT [Id] FROM @dms_changed [i] WHERE [t].[Id] = [i].[Id] )
END GO`
and .NetCore code, I set SyncOptions as below:
SyncOptions syncOption = new SyncOptions { ConflictResolutionPolicy = ConflictResolutionPolicy.ClientWins };

What is the solution to this issue? Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (6 by maintainers)

Top Related StackOverflow Question
I’m currently in vacation, but I guess, the next release will be released in early September
I already tested OK following your suggestion. When is version 0.8.1 release? I’m looking forward to applying this.