Consider the following scenario:
You use sp_cdc_cleanup_change_table to manage the change table cleanup process.
A deadlock occurs between the change data capture (CDC) scan and CDC cleanup when sp_cdc_cleanup_change_table is invoked.
In this scenario, the following error 22852 with severity 10 (informational message) occurs:
Could not delete change table entries made obsolete by a change in one or more low water marks for capture instances of database <DatabaseName>. The failure occurred when executing the command <CommandName>. The error returned was <ErrorInfo>.
Use the action and error to determine the cause of the failure and resubmit the request.
Note Because this is an informational message, the cleanup process doesn't fail, and there's no way to determine whether the cleanup succeeds or fails.
Details about the fix
To determine whether the cleanup succeeds or fails when you use sp_cdc_cleanup_change_table, an optional output parameter (fCleanupFailed bit) is added to sp_cdc_cleanup_change_table function. This can be used to check whether the cleanup of any capture instances fails. If fCleanupFailed output is 0, all the cleanup succeeds. If it is 1, at least the cleanup of one capture instance fails. Here is an example:
-- Declaring a variable and Setting to zero first
select @cleanup_failed_bit = 0
--Execute cleanup and obtain output bit
EXEC @retcode =sys.sp_cdc_cleanup_change_table
@capture_instance = '<CaptureInstance>',
@low_water_mark = @LSN,
@threshold = 1 ,
@fCleanupFailed = @cleanup_failed_bit output
--Leverage @cleanup_failed_bit output to check the status.
This problem is fixed in the following cumulative updates for SQL Server:
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Learn about the terminology that Microsoft uses to describe software updates.