Table of Contents

Class StalePositionReasonCodes

Namespace
Excalibur.Cdc.SqlServer
Assembly
Excalibur.Cdc.SqlServer.dll

Provides standardized reason codes for CDC stale position scenarios.

public static class StalePositionReasonCodes
Inheritance
StalePositionReasonCodes
Inherited Members

Remarks

These codes are used in ReasonCode to categorize why a CDC position became invalid. This enables consistent logging, alerting, and handling across different stale position scenarios.

Fields

BackupRestore

The position is invalid after a database backup and restore operation.

public const string BackupRestore = "BACKUP_RESTORE"

Field Value

string

Remarks

This occurs when a database is restored from a backup taken before the saved LSN, or when a lower environment receives a copy of production data with different CDC history.

CaptureInstanceDropped

The capture instance no longer exists in the database.

public const string CaptureInstanceDropped = "CAPTURE_INSTANCE_DROPPED"

Field Value

string

Remarks

This occurs when a table's CDC capture instance has been dropped, either explicitly or by dropping the source table.

CdcCleanup

The position was purged by the CDC cleanup job (sys.sp_cdc_cleanup_change_tables).

public const string CdcCleanup = "CDC_CLEANUP"

Field Value

string

Remarks

This occurs when the CDC retention period expires and cleanup purges records older than the retention threshold. The saved LSN points to purged data.

CdcReenabled

CDC was disabled and re-enabled on the database, invalidating existing positions.

public const string CdcReenabled = "CDC_REENABLED"

Field Value

string

Remarks

When CDC is disabled (sys.sp_cdc_disable_db) and re-enabled, all capture instances are recreated and previous LSN values are no longer valid.

LsnOutOfRange

The LSN is outside the valid range of available change data.

public const string LsnOutOfRange = "LSN_OUT_OF_RANGE"

Field Value

string

Remarks

This is a general error when the LSN falls outside the min/max LSN range available in the CDC change tables, typically SQL Error 22037 or 22029.

TvfInsufficientArguments

The CDC table-valued function received an invalid LSN range, reported as SQL Error 313 ("An insufficient number of arguments were supplied").

public const string TvfInsufficientArguments = "TVF_INSUFFICIENT_ARGUMENTS"

Field Value

string

Remarks

This occurs when cdc.fn_cdc_get_all_changes_* is called with an LSN that falls outside the valid CDC window. Certain boundary conditions cause SQL Server to raise error 313 instead of the more specific 22037/22029 errors. The practical effect is the same: the saved position is stale and must be reset.

Unknown

The reason for the stale position could not be determined.

public const string Unknown = "UNKNOWN"

Field Value

string

Remarks

This is used when the specific cause cannot be identified from the SQL error or when an unexpected error occurs during position validation.

Methods

FromSqlError(int)

Determines the reason code from a SQL Server error number.

public static string FromSqlError(int sqlErrorNumber)

Parameters

sqlErrorNumber int

The SQL Server error number.

Returns

string

The corresponding reason code.