Table of Contents

Class PostgresStalePositionDetector

Namespace
Excalibur.Cdc.Postgres
Assembly
Excalibur.Cdc.Postgres.dll

Detects and classifies stale CDC position errors from Postgres exceptions.

public static class PostgresStalePositionDetector
Inheritance
PostgresStalePositionDetector
Inherited Members

Fields

ConnectionFailure

Postgres SQLSTATE for connection failure.

public const string ConnectionFailure = "08006"

Field Value

string

FeatureNotSupported

Postgres SQLSTATE for feature not supported (e.g., wal_level not logical).

public const string FeatureNotSupported = "0A000"

Field Value

string

ObjectNotInPrerequisiteState

Postgres SQLSTATE for object not in prerequisite state (replication slot invalid).

public const string ObjectNotInPrerequisiteState = "55000"

Field Value

string

ProtocolViolation

Postgres SQLSTATE for protocol violation (logical decoding issues).

public const string ProtocolViolation = "08P01"

Field Value

string

UndefinedObject

Postgres SQLSTATE for undefined object (publication/slot not found).

public const string UndefinedObject = "42704"

Field Value

string

WalSegmentNotAccessible

Postgres SQLSTATE for WAL segment not accessible (could_not_access_file).

public const string WalSegmentNotAccessible = "58P01"

Field Value

string

Properties

StalePositionSqlStates

Gets the set of Postgres SQLSTATE codes that indicate a stale CDC position.

public static IReadOnlySet<string> StalePositionSqlStates { get; }

Property Value

IReadOnlySet<string>

Methods

CreateEventArgs(Exception, string, PostgresCdcPosition?, PostgresCdcPosition?, string?, string?, string?)

Creates a CdcPositionResetEventArgs from an exception and context.

public static CdcPositionResetEventArgs CreateEventArgs(Exception exception, string processorId, PostgresCdcPosition? stalePosition = null, PostgresCdcPosition? newPosition = null, string? replicationSlot = null, string? publication = null, string? databaseName = null)

Parameters

exception Exception
processorId string
stalePosition PostgresCdcPosition?
newPosition PostgresCdcPosition?
replicationSlot string
publication string
databaseName string

Returns

CdcPositionResetEventArgs

GetReasonCode(PostgresException?)

Determines the appropriate reason code from a Postgres exception.

public static string GetReasonCode(PostgresException? exception)

Parameters

exception PostgresException

Returns

string

GetStalePositionSqlState(Exception?)

Extracts the SQLSTATE code that indicates a stale position from the exception.

public static string? GetStalePositionSqlState(Exception? exception)

Parameters

exception Exception

Returns

string

IsStalePositionException(Exception?)

Determines whether the specified exception indicates a stale CDC position.

public static bool IsStalePositionException(Exception? exception)

Parameters

exception Exception

Returns

bool

IsStalePositionSqlState(string?)

Determines if a SQLSTATE code indicates a stale position scenario.

public static bool IsStalePositionSqlState(string? sqlState)

Parameters

sqlState string

Returns

bool