Skip to content

[Bug][Connector-V2][Postgres-CDC] Handle duplicate replication slot by SQL state#11166

Closed
LeonYoah wants to merge 1 commit into
apache:devfrom
LeonYoah:lyb/fix-pg-cdc-slot-sqlstate-dev
Closed

[Bug][Connector-V2][Postgres-CDC] Handle duplicate replication slot by SQL state#11166
LeonYoah wants to merge 1 commit into
apache:devfrom
LeonYoah:lyb/fix-pg-cdc-slot-sqlstate-dev

Conversation

@LeonYoah

Copy link
Copy Markdown
Collaborator

Purpose of this pull request

Fixes #10992.

Postgres CDC should not depend on a localized error message to detect an existing replication slot. This PR keeps the SQLState 42710 check and moves it into a helper, with the old English message check as a fallback.

Basis:

  • PostgreSQL documents 42710 as duplicate_object in PG 13 and current PG.
  • PostgreSQL replication slot creation reports a duplicate slot name with ERRCODE_DUPLICATE_OBJECT: slot.c.

Does this PR introduce any user-facing change?

Yes. When the replication slot already exists and PostgreSQL returns a localized message, Postgres CDC logs a warning and continues.

How was this patch tested?

JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home ./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres -am -DskipITs -Dcheckstyle.skip -Dspotless.check.skip=true -Dlicense.skip=true -DskipTests install
JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home ./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres -DskipITs -Dcheckstyle.skip -Dspotless.check.skip=true -Dlicense.skip=true -Dtest=PostgresSourceFetchTaskContextTest test
JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home ./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres -DskipITs -Dcheckstyle.skip -Dlicense.skip=true spotless:check
git diff --check

Local reproduction:

  • PG 13 zh_CN returned sqlState=42710 and message 错误: 复制槽名 "seatunnel" 已经存在.
  • Before the fix, SeaTunnel failed at PostgresSourceFetchTaskContext.
  • After the fix, SeaTunnel logged the existing-slot warning, entered incremental mode, and Console received INSERT : 4, delta_fix.
  • PG 18.3 also returned sqlState=42710 for a duplicated replication slot.

Check list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to create replication slot when using the initial mode for pg-cdc in Apache SeaTunnel 3.13

1 participant