Skip to content

[Feature][Connector-V2] Support PostgreSQL CDC ADD COLUMN schema evolution - #11922

Merged
davidzollo merged 3 commits into
apache:devfrom
dybyte:feature/postgresql-cdc-schema-evolution
Sep 7, 2026
Merged

davidzollo merged 3 commits into
apache:devfrom
dybyte:feature/postgresql-cdc-schema-evolution

Conversation

@dybyte

@dybyte dybyte commented Aug 21, 2026

Copy link
Copy Markdown
Member

Related to: #10777

Purpose of this pull request

This PR partially addresses #10777 by supporting PostgreSQL CDC ADD COLUMN schema evolution.

PostgreSQL pgoutput does not provide the original DDL statement to Debezium. Instead of parsing DDL, this PR:

  • Detects updated table metadata from pgoutput RELATION messages.
  • Compares it with SeaTunnel's authoritative CatalogTable, including checkpoint-restored schemas.
  • Emits an ADD COLUMN schema event before the following DML record.
  • Reuses the existing schema evolution and checkpoint coordination path to update downstream sinks.

Does this PR introduce any user-facing change?

Yes.

Users can enable PostgreSQL CDC ADD COLUMN synchronization with:

decoding.plugin.name = "pgoutput"
schema-changes.enabled = true

Currently only appended ADD COLUMN changes are supported. Other row-schema changes fail fast before processing DML with the unsupported schema.
The option is disabled by default, so existing jobs are unaffected.

How was this patch tested?

  • Unit tests: verify multiple ADD COLUMN detection, unchanged-schema skipping, and fail-fast behavior for unsupported changes.
  • E2E test: verifies that savepoint recovery detects a source-only BIGINT column addition, evolves the sink schema, and replicates the new row.

Check list

@dybyte
dybyte force-pushed the feature/postgresql-cdc-schema-evolution branch from f05287d to 065655d Compare August 21, 2026 12:05
@dybyte
dybyte marked this pull request as ready for review August 21, 2026 12:05
@dybyte
dybyte requested a review from zhangshenghang August 21, 2026 13:32

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Problem Does This PR Solve?

  • User pain point: PostgreSQL's logical replication (pgoutput) never carries the original DDL text, so unlike MySQL/Oracle/SQLServer CDC, the PostgreSQL connector could not previously propagate ADD COLUMN changes to downstream sinks — every existing job silently kept using the schema captured at job start.
  • Fix approach: subclass Debezium's PostgresSchema to intercept pgoutput RELATION messages, diff the new relation against SeaTunnel's own tracked CatalogTable (including the checkpoint/savepoint-restored one on restart), synthesize a schema-change SourceRecord, and plug into the same generic SchemaChangeResolver / TableSchemaChangeEventDispatcher machinery already used by MySQL/Oracle/SQLServer CDC.
  • One-sentence summary: A well-integrated, opt-in (schema-changes.enabled=false by default) implementation of ADD COLUMN schema evolution for PostgreSQL CDC that correctly reuses existing generic schema-evolution/checkpoint infrastructure, with one real fail-fast gap in its own new error-handling code.

1. Code Change Review

1.1 Core Logic Analysis

I traced the full runtime path end to end rather than just the diff hunks, since this touches the CDC streaming/checkpoint-recovery path:

pgoutput RELATION message
  → PostgresStreamingChangeEventSource decodes it (Debezium, unmodified)
  → RelationAwarePostgresSchema.applySchemaChangesForTable(relationId, table)   [new subclass hook]
      → super.applySchemaChangesForTable(...)   (Debezium's own schema update, unchanged)
      → if (relationChangeListener != null && previousTable != null) listener.accept(table)
  → PostgresSourceFetchTaskContext.dispatchRelationSchemaChange(table)          [new]
      → dedup against lastRelationSchemas (in-memory, per-task, cleared in configure())
      → dedup against relationSchemaBaseline (checkpoint-restored CatalogTable list, or
        initial discovery list if no checkpoint) via hasSameBaselineSchema()
      → queue.enqueue(new DataChangeEvent(PostgresRelationSchemaRecord.create(...)))
        [same ChangeEventQueue used for ordinary DML — enqueue happens synchronously on the
         same decoder thread, before the DML record for the same relation is decoded/enqueued,
         so FIFO ordering guarantees "schema event before the triggering DML row" as documented]
  → SeaTunnelRowDebeziumDeserializeSchema.deserialize(record, collector)
      → isSchemaChangeEvent(record) is true (SourceRecordUtils now recognizes
        "io.debezium.connector.postgresql.SchemaChangeKey", matching
        PostgresRelationSchemaRecord.KEY_SCHEMA_NAME exactly)
      → deserializeSchemaChangeRecord(record, collector)
          → schemaChangeResolver.resolve(record, tables)  [PostgresRelationSchemaChangeResolver]
              → extractTable(record) / findCatalogTable(after, catalogTables)
              → resolveAddedColumns(before, after): validates the first N columns are
                unchanged (name/type/nullable), then builds AlterTableAddColumnEvent(s) for
                any trailing new columns; throws SchemaValidationException for anything else
                (drop/rename/retype/reorder)
          → mutates this.tables in place and applies the event via
            TableSchemaChangeEventDispatcher (pre-existing, shared with MySQL/Oracle/SQLServer)

I confirmed this is the normal execution path, not a boundary/recovery-only path: with schema-changes.enabled=true (opt-in) and decoding.plugin.name=pgoutput (enforced by a new validateSchemaEvolutionOptions guard at source-construction time), every ADD COLUMN on a tracked table goes through this exact chain during ordinary streaming.

Checkpoint/restore correctness — I verified this specifically since it's the highest-risk part of the claim ("including checkpoint-restored schemas"):

  • PostgresDialect.java now builds relationSchemaBaseline from sourceSplitBase.asIncrementalSplit().getCheckpointTables() when present (i.e. a genuine restart from a checkpoint), falling back to the freshly-discovered tableMap.values() otherwise. IncrementalSplit.getCheckpointTables() is pre-existing, generic CDC-restore infrastructure (not touched by this PR), already relied on by other connectors' schema-evolution support.
  • On restart, lastRelationSchemas is empty (cleared in configure()), so the first RELATION message Debezium sends for a table (which pgoutput always sends once per table per new replication connection) is compared against relationSchemaBaseline, i.e. the checkpoint-restored schema, not whatever Debezium's live in-memory schema happens to be. This correctly avoids re-emitting a schema-change event for a change that was already applied and checkpointed before the restart — I confirmed this matches the E2E test testAddColumnSchemaEvolutionWithRestore, which does exactly this scenario (savepoint → source-only ADD COLUMN → restore → assert sink evolves before the first new row) and asserts both row content and the sink's actual information_schema.columns data type.

Key Findings (see Issue 1 below for the one genuine correctness gap I found):

  • resolveAddedColumns only supports columns appended at the physical end of the table, which is the only shape PostgreSQL's ADD COLUMN can ever produce (Postgres has no positional ADD COLUMN ... AFTER), so this isn't an artificial restriction — it exactly matches what pgoutput can send.
  • Column-count-shrink, type change, nullability change, or rename are all correctly detected and rejected via unsupportedChange() (SchemaValidationException, fail-fast — verified the exception class chain: SchemaValidationException extends SchemaEvolutionException extends SeaTunnelRuntimeException, and SeaTunnelRowDebeziumDeserializeSchema's new catch (SchemaEvolutionException e) { throw e; } re-throws it rather than swallowing it like the generic catch (Exception e) branch below it does).

Issue 1 (High) — see section 1.4 is the one place where this careful fail-fast design has a gap: a different failure mode in the same resolver (table lookup failure) is not classified as a SchemaEvolutionException and is silently swallowed instead.

1.2 Compatibility Impact

Partially incompatible, but only via one unconditional side effect (Issue 2); otherwise fully compatible and additive.

  • The main feature is strictly opt-in: schema-changes.enabled defaults to false, which reproduces the previously-hardcoded include.schema.changes=false Debezium property exactly — I verified schemaChangeEnabled is set from JdbcSourceOptions.SCHEMA_CHANGES_ENABLED (default false) on the shared JdbcSourceConfigFactory base class. With it disabled, databaseSchema.setRelationChangeListener(...) is never called, so RelationAwarePostgresSchema.applySchemaChangesForTable behaves identically to the old PostgresSchema (the if (relationChangeListener != null ...) guard is false) — no behavior change for any existing job that doesn't opt in.
  • PostgresObjectUtils.newSchema's return type changing from PostgresSchema to RelationAwarePostgresSchema is a compatible covariant change (subtype).
  • Issue 2 below is the one place a shared helper's behavior changes unconditionally for all PostgreSQL CDC jobs, not just opted-in ones.

1.3 Performance / Side-Effect Analysis

  • dispatchRelationSchemaChange only runs when schema-changes.enabled=true; for disabled jobs there is zero added overhead (listener not registered).
  • When enabled, the added work per RELATION message is a HashMap.put + a linear scan over relationSchemaBaseline/comparison of columns — bounded by table/column count, not a hot-row-level path (RELATION messages are far rarer than DML).
  • lastRelationSchemas is an unbounded-but-table-cardinality-bounded HashMap (one entry per distinct table seen), cleared per configure() call — no leak risk given normal table counts.

1.4 Error Handling and Logging

Issue 1: Table-lookup failures in the resolver are silently swallowed instead of failing fast, undermining the PR's own fail-fast design

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/source/PostgresRelationSchemaChangeResolver.java:70-97 (extractTable/findCatalogTable), consumed by seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:134-142.
  • Problem: resolve() throws a plain IllegalArgumentException when the pgoutput TableChanges array is empty (extractTable, line 77-78) or when the RELATION's table can't be matched by schema+table name against the job's catalogTables (findCatalogTable, line 92-96). deserializeSchemaChangeRecord's new catch (SchemaEvolutionException e) { throw e; } block — added specifically by this PR to make unsupportedChange()'s SchemaValidationException fail the job — does not catch IllegalArgumentException; it falls into the pre-existing catch (Exception e) { log.warn(...); return; } branch (kept for backward compatibility with other resolvers' generic parse failures) and is silently discarded.
  • Potential risk: if a real ADD COLUMN happens on an in-scope table but the lookup fails — e.g. a schema-name mismatch between how CatalogTable.getTablePath() stores it and how Table.id() reports it after ConnectTableChangeSerializer deserialization (the resolver's own relationSchemaName() comment documents exactly this kind of catalog/schema-field ambiguity as something to "fall back" on) — the entire schema-change event for that table is dropped with only a WARN log line. this.tables is never updated, the sink is never told to add the column, and subsequent DML rows for that table continue to be deserialized against the stale schema. This is precisely the "produced row schema diverges from the source relation" scenario the PR's own code comment says SchemaEvolutionException exists to prevent — but this particular divergence path doesn't use it. There is no test exercising the "table not found" branch (PostgresRelationSchemaChangeResolverTest only covers found-and-matching, found-and-unchanged, and found-with-unsupported-change), so nothing currently guards against this.
  • Best improvement: have extractTable/findCatalogTable throw a SchemaValidationException (or another SchemaEvolutionException subtype) with a clear message, consistent with unsupportedChange(), so a genuine lookup failure fails the job the same way an unsupported column change does. Add a unit test for the "table not found" case.
  • Severity: High
  • Raised by another reviewer: No

Issue 2: The shared PostgresTypeUtils.convertToTypeDefine() refactor unconditionally changes type-resolution behavior for all existing PostgreSQL CDC jobs, not just schema-evolution users

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/utils/PostgresTypeUtils.java:30-45; consumed unconditionally by PostgresChunkSplitter.java:123 / PostgresUtils.java:279 (snapshot chunk-splitting column type resolution — runs for every PostgreSQL CDC job's initial snapshot, regardless of schema-changes.enabled).
  • Problem: the extracted convertToTypeDefine helper — now shared between the pre-existing convertFromColumn and the new resolver's convertToSeaTunnelColumn — newly populates .sqlType(column.jdbcType()), which was never set before this PR. I traced PostgresTypeConverter.convert() (seatunnel-connectors-v2/connector-jdbc/.../PostgresTypeConverter.java:288) and found its default: branch treats sqlType == Types.OTHER as "fall back to STRING_TYPE" instead of throwing CommonError.convertToSeaTunnelTypeError. Since sqlType was previously always unset (defaulting to 0, never equal to Types.OTHER/1111) for this call path, that fallback branch was unreachable — any PostgreSQL column type not in the named switch (custom enums, some extension/PostGIS types) would throw for every existing CDC job. Now such columns silently resolve to STRING instead.
  • Potential risk: narrow blast radius in practice (convertFromColumn is only used to type the snapshot-chunking split column, not general schema construction), and the net effect — no longer crashing on previously-unmappable types — is arguably a fix, not a regression. But it's an undocumented, untested, unconditional behavior change bundled into an opt-in feature PR: it applies even to jobs with schema-changes.enabled=false and isn't mentioned anywhere in the "any user-facing change" section of the PR description.
  • Best improvement: call this out explicitly in the PR description as an intentional side-fix (or split it into its own PR), and add a unit test asserting the new Types.OTHER → STRING fallback.
  • Severity: Medium
  • Raised by another reviewer: No

Issue 3: Several new non-trivial methods/fields central to the new feature are missing doc comments

  • Location: PostgresRelationSchemaChangeResolver.hasSameSchema(CatalogTable, Table) (no javadoc); RelationAwarePostgresSchema.hasSameSchema(Table, Table) (no javadoc); PostgresRelationSchemaRecord.create(...) (no javadoc beyond the one-line class comment); PostgresSourceFetchTaskContext.dispatchRelationSchemaChange/hasSameBaselineSchema (no comment on this fairly intricate dedup logic); fields lastRelationSchemas and relationSchemaBaseline on PostgresSourceFetchTaskContext (no comment explaining lifecycle/purpose, despite being central to the checkpoint-dedup correctness traced in 1.1).
  • Potential risk: this is exactly the kind of "why does this dedup exist, what does it protect against on restart" logic that's hard to reverse-engineer without a comment — a future maintainer touching checkpoint/restore behavior here is likely to break the dedup semantics without realizing it.
  • Best improvement: add doc comments explaining what each dedup layer protects against (in-memory duplicate suppression within a task's lifetime vs. checkpoint-restore duplicate suppression across restarts).
  • Severity: Medium
  • Raised by another reviewer: No

Issue 4 (Low, maintainability): naming collision between two structurally similar but semantically different hasSameSchema helpers

  • Location: io.debezium.connector.postgresql.RelationAwarePostgresSchema.hasSameSchema(Table, Table) (compares raw Debezium tables, including primary-key column names) vs. PostgresRelationSchemaChangeResolver.hasSameSchema(CatalogTable, Table) (compares SeaTunnel-converted columns only, no PK comparison). Both are correct for their respective call sites, but the identical name with differing semantics/parameter types is a latent confusion risk. Consider renaming one, e.g. hasSameRelationSchema vs. hasSameCatalogSchema.
  • Severity: Low
  • Raised by another reviewer: No

2. Code Quality Assessment

2.1 Coding Standards

See Issue 3 above (Medium) — several new non-trivial methods/fields lack doc comments. Otherwise the code follows existing conventions in this module (matches the style of the sibling MySQL/Oracle/SQLServer SchemaChangeResolver implementations).

2.2 Test Coverage and Test Stability

  • Unit tests (PostgresRelationSchemaChangeResolverTest): deterministic, no Thread.sleep, no shared mutable static state, table/column fixtures built directly via Debezium's Table.editor()/Column.editor(). Good coverage of the happy path (multi-column ADD), no-op path, and unsupported-change path — but missing the "table not found" path that Issue 1 depends on.
  • E2E test (PostgresCDCIT.testAddColumnSchemaEvolutionWithRestore, renamed/extended from the pre-existing testAddFieldWithRestore): uses Awaitility.await().atMost(60000, MILLISECONDS).untilAsserted(...) throughout — no raw Thread.sleep, no fixed waits, consistent with the file's established pattern. It genuinely exercises the checkpoint-restore scenario (savepoint → source-only ADD COLUMN → restore → assert row content and sink-side information_schema.columns data type), which is the highest-value scenario for this feature. dropFieldIfExists in the finally block correctly avoids leaving mutated schema state for subsequent test runs.
  • Rating: Stable. No flaky patterns found in either the new/changed unit or E2E tests. (The coverage gap in Issue 1 is a correctness gap, not a stability/flakiness concern, so it's tracked separately above.)

2.3 Documentation Updates

docs/en/connectors/source/PostgreSQL-CDC.md and docs/zh/... both add the three new options to the option table and a worked example section. I verified the documented behavior matches the source: the docs honestly disclose the "a table must receive a row change after the DDL before the schema change can be observed" limitation (matches dispatchRelationSchemaChange only firing on the next RELATION message, which pgoutput only sends alongside a subsequent row event) and the "job fails before processing rows with that schema" behavior for unsupported changes (matches unsupportedChange() + the new fail-fast catch, modulo Issue 1's gap). Good, accurate documentation.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix / long-term solution, not a workaround. Rather than inventing a parallel schema-evolution mechanism for PostgreSQL, this correctly plugs into the existing generic SchemaChangeResolver / TableSchemaChangeEventDispatcher / SupportSchemaEvolution / checkpoint-table-restore infrastructure already proven by MySQL/Oracle/SQLServer CDC. The Debezium-internals subclassing (RelationAwarePostgresSchema, PostgresObjectUtils) follows a pattern the connector-cdc-postgres module already used pre-PR (this isn't the first SeaTunnel-owned class living under io.debezium.connector.postgresql in this module), so it isn't introducing a new category of fragility.

3.2 Maintainability

Good overall, held back by Issue 3 (missing comments on the trickiest new logic — the checkpoint-restore dedup) and the mild Issue 4 naming collision. The reuse of the existing include.schema.changes Debezium property as the internal toggle (rather than inventing a new one) is a reasonable, minimal-footprint choice, though it does mean this feature's activation is coupled to a Debezium connector option whose upstream semantics could shift on a future Debezium version bump — worth a one-line comment (it already has one, at PostgresSourceConfigFactory.java:112-114, which is good).

3.3 Extensibility

The resolver's structure (support()/resolve()) and SchemaChangeType.ADD_COLUMN-only supports() declaration make it straightforward to extend to other change types later without touching the dispatch plumbing.

3.4 Historical-Version Compatibility

Verified: default-disabled feature flag reproduces the prior hardcoded Debezium property value exactly (see 1.2), so existing running/checkpointed jobs are unaffected by the main feature. The one real compatibility caveat is Issue 2 (unconditional Types.OTHER fallback change) — narrow blast radius, but real and undocumented. No checkpoint/savepoint serialization format changes; IncrementalSplit/getCheckpointTables() (the mechanism this PR relies on for restore-time dedup) is pre-existing and untouched by this PR.

4. Issue Summary

# Issue Location Severity
1 Table-lookup failures in the resolver are silently swallowed instead of failing fast PostgresRelationSchemaChangeResolver.java:70-97, SeaTunnelRowDebeziumDeserializeSchema.java:134-142 High
2 Shared type-conversion refactor unconditionally changes existing-job behavior (Types.OTHER → STRING fallback), undocumented/untested PostgresTypeUtils.java:30-45 Medium
3 Several new non-trivial methods/fields lack doc comments PostgresRelationSchemaChangeResolver.java, RelationAwarePostgresSchema.java, PostgresRelationSchemaRecord.java, PostgresSourceFetchTaskContext.java Medium
4 hasSameSchema name reused for two semantically different comparisons RelationAwarePostgresSchema.java vs. PostgresRelationSchemaChangeResolver.java Low

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed (sorted by severity):
    • Issue 1 (High): classify the table-lookup failure path as a SchemaEvolutionException (or otherwise make it fail fast) so it isn't silently absorbed by the generic backward-compatibility catch block. This is the one place where the implementation's own stated design goal ("fail fast for unsupported schema changes") isn't actually met, and it's exactly the kind of gap that's invisible until a specific naming-mismatch edge case hits it in production with no job failure and only a WARN log to notice by.
  2. Recommended fixes — non-blocking:
    • Issue 2 (Medium): document (or split out) the unconditional Types.OTHER fallback behavior change and add a test for it.
    • Issue 3 (Medium): add doc comments to the new dedup/dispatch logic, particularly the two hasSameSchema-family checks and the lastRelationSchemas/relationSchemaBaseline fields — this is genuinely the trickiest part of the change to safely maintain later.
    • Issue 4 (Low): rename one of the two hasSameSchema overloads for clarity.

Overall assessment: this is a substantial, carefully-designed feature that correctly reuses SeaTunnel's existing generic CDC schema-evolution and checkpoint-restore machinery rather than reinventing it, and the E2E test genuinely proves the highest-value scenario (savepoint restore across an ADD COLUMN). The one High-severity gap (Issue 1) is narrow in scope but real, and is exactly the sort of edge case that a "fail fast, never silently diverge" design should not have left open in its own new code. I'd want Issue 1 fixed before merge; Issues 2-4 can reasonably follow in a fast-follow if the author prefers, but ideally land alongside since they're all small, targeted changes to files already touched by this PR.

Note on CI: at review time the "Build" check on this PR was still in progress (not yet green); this review is based on static/source-level analysis only, per project convention that all compile/test verification for Apache SeaTunnel PRs is CI-authoritative. Please confirm CI is fully green on this exact head commit before merging regardless of the above.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Problem Does This PR Solve?

  • User pain point: PostgreSQL's logical replication (pgoutput) never carries the original DDL text, so unlike MySQL/Oracle/SQLServer CDC, the PostgreSQL connector could not previously propagate ADD COLUMN changes to downstream sinks — every existing job silently kept using the schema captured at job start.
  • Fix approach: subclass Debezium's PostgresSchema to intercept pgoutput RELATION messages, diff the new relation against SeaTunnel's own tracked CatalogTable (including the checkpoint/savepoint-restored one on restart), synthesize a schema-change SourceRecord, and plug into the same generic SchemaChangeResolver / TableSchemaChangeEventDispatcher machinery already used by MySQL/Oracle/SQLServer CDC.
  • One-sentence summary: A well-integrated, opt-in (schema-changes.enabled=false by default) implementation of ADD COLUMN schema evolution for PostgreSQL CDC that correctly reuses existing generic schema-evolution/checkpoint infrastructure, and the follow-up commit closes every gap raised in the previous round.

1. Code Change Review

1.1 Core Logic Analysis

This is a full re-review of the entire current diff (git diff dev...pr-11922, head 60f0c64c11), re-traced from scratch rather than assuming my previous pass still holds.

Complete runtime path (streaming path, the normal execution path once schema-changes.enabled=true):

pgoutput RELATION message
  → PostgresStreamingChangeEventSource decodes it (Debezium, unmodified)
  → RelationAwarePostgresSchema.applySchemaChangesForTable(relationId, table)   [new subclass hook]
      → super.applySchemaChangesForTable(...)   (Debezium's own schema update, unchanged)
      → if (relationChangeListener != null && previousTable != null) listener.accept(table)
        [when the feature is disabled, relationChangeListener is never set (see 1.2), so this is a
         no-op wrapper and behaves byte-for-byte like the old PostgresSchema]
  → PostgresSourceFetchTaskContext.dispatchRelationSchemaChange(table)          [new]
      → dedup against lastRelationSchemas (in-memory, per-task, cleared in configure())
        via RelationAwarePostgresSchema.hasSameRelationSchema()
      → dedup against relationSchemaBaseline (checkpoint-restored CatalogTable list, or initial
        discovery list if no checkpoint) via PostgresRelationSchemaChangeResolver.hasSameCatalogSchema()
      → queue.enqueue(new DataChangeEvent(PostgresRelationSchemaRecord.create(...)))
        [same ChangeEventQueue used for ordinary DML — enqueue happens synchronously on the same
         decoder thread, before the DML record for the same relation is decoded/enqueued (pgoutput
         always sends RELATION immediately before any INSERT/UPDATE/DELETE that references it), so
         FIFO ordering guarantees "schema event before the triggering DML row" as documented]
  → SeaTunnelRowDebeziumDeserializeSchema.deserialize(record, collector)
      → isSchemaChangeEvent(record) is true (SourceRecordUtils now recognizes
        "io.debezium.connector.postgresql.SchemaChangeKey", matching
        PostgresRelationSchemaRecord.KEY_SCHEMA_NAME exactly)
      → deserializeSchemaChangeRecord(record, collector)
          → schemaChangeResolver.resolve(record, tables)  [PostgresRelationSchemaChangeResolver]
              → extractTable(record) / findCatalogTable(after, catalogTables)
              → resolveAddedColumns(before, after): validates the first N columns are unchanged
                (name/type/nullable), then builds AlterTableAddColumnEvent(s) for any trailing new
                columns; throws SchemaValidationException for anything else (drop/rename/retype/
                reorder/missing-table/empty-payload — all four failure modes now share one
                exception family, see "Issue 1 fixed" below)
          → mutates this.tables in place and applies the event via TableSchemaChangeEventDispatcher
            (pre-existing, shared with MySQL/Oracle/SQLServer)

I re-verified this is the normal execution path, not a boundary/recovery-only path: with schema-changes.enabled=true (opt-in) and decoding.plugin.name=pgoutput (enforced by validateSchemaEvolutionOptions at source-construction time), every ADD COLUMN on a tracked table goes through this exact chain during ordinary streaming.

Race between the DDL/schema event and concurrently-buffered DML for old-vs-new-schema rows: not present. dispatchRelationSchemaChange and the ordinary DML dispatch both go through the identical queue.enqueue(...) call on the same single Debezium streaming/decoder thread. Postgres's own logical-replication protocol guarantees a RELATION message for a table precedes any subsequent Insert/Update/Delete referencing that relation on the same connection, and Debezium decodes messages strictly in stream order. Since the schema record and the DML rows share one FIFO queue with a single producer thread, there is no window where a DML row for the new schema can be dequeued/deserialized before its preceding schema-change record — the resolver mutates this.tables synchronously before returning control to the DML deserialization path for the very next record.

Does an in-flight job evolve without restart? Yes — verified this is a live streaming-path callback (applySchemaChangesForTable, invoked per RELATION message as they arrive), not a snapshot/job-start-only path. No source restart is required; the sink receives the AlterTableAddColumnEvent the same way MySQL/Oracle/SQLServer sinks already do, via TableSchemaChangeEventDispatcher.

Checkpoint/restore correctness — re-verified end to end since it's the highest-risk part of the claim ("including checkpoint-restored schemas"):

  • PostgresDialect.java builds relationSchemaBaseline from sourceSplitBase.asIncrementalSplit().getCheckpointTables() when present (genuine restart from checkpoint), falling back to the freshly-discovered tableMap.values() otherwise. IncrementalSplit.getCheckpointTables() is pre-existing, generic CDC-restore infrastructure, untouched by this PR.
  • PostgresIncrementalSourceFactory now extends the shared BaseChangeStreamTableSourceFactory (I confirmed MySQL's and Oracle's factories already extend the same base class) and calls the same pre-existing mergeTableStruct(catalogTables, restoreTables) helper that MySQL/Oracle already use for their own restore path — this isn't a new mechanism invented for Postgres, it's the proven shared one, gated the same way MySQL gates it (!restoreTables.isEmpty() && <schema-change-enabled flag>).
  • On restart, lastRelationSchemas is empty (cleared in configure()), so the first RELATION message for a table is compared against relationSchemaBaseline (the checkpoint-restored schema), not whatever Debezium's live in-memory schema happens to be — this avoids re-emitting an event for a change already applied and checkpointed before the restart. This matches the E2E test testAddColumnSchemaEvolutionWithRestore (savepoint → source-only ADD COLUMN → restore → assert both row content and the sink's actual information_schema.columns data type).

Follow-up commit 60f0c64c11 — verifying every fix from my previous round, from scratch, not by assumption:

  • Issue 1 (High, "table-lookup failures silently swallowed") — confirmed fixed. extractTable/findCatalogTable now throw invalidRelationRecord(...) → new SchemaValidationException(SchemaEvolutionErrorCode.INVALID_SCHEMA_STRUCTURE, ...) for all three failure modes (empty TABLE_CHANGES payload, no table found in the deserialized changes, and no matching CatalogTable), instead of the old plain IllegalArgumentException. I traced SchemaValidationException extends SchemaEvolutionException, and SeaTunnelRowDebeziumDeserializeSchema's catch (SchemaEvolutionException e) { throw e; } block (unchanged in this commit, still ordered before the generic catch (Exception e)) now genuinely catches this path — the job fails fast instead of silently dropping the schema-change event. A new unit test, shouldRejectRelationWhenCachedTableIsMissing, exercises exactly the "table not found" branch that was previously untested. I confirmed SchemaEvolutionErrorCode.INVALID_SCHEMA_STRUCTURE ("SE-05") is a pre-existing enum constant in the shared seatunnel-api module, not a new one added by this PR, so this reuses an existing, already-plumbed error code rather than inventing a parallel one.
  • Issue 2 (Medium, "shared type-conversion refactor unconditionally changes existing-job behavior") — confirmed fixed, and fixed the right way. PostgresTypeUtils.convertFromColumn (used unconditionally by every PostgreSQL CDC job's snapshot chunk-splitting, regardless of schema-changes.enabled) no longer calls the shared helper at all — it now builds its own inline BasicTypeDefine that does not set .sqlType(...), reproducing the exact pre-PR behavior byte-for-byte (only cosmetic one-line simplification of the return statement). The .sqlType(column.jdbcType()) addition — and the Types.OTHER → STRING fallback behavior it triggers in PostgresTypeConverter.convert() — now lives exclusively in the new convertRelationColumnToTypeDefine, which is reachable only from PostgresRelationSchemaChangeResolver.convertToSeaTunnelColumn, itself only reachable when schema-changes.enabled=true and a RELATION event fires. This closes the blast radius to exactly the opt-in feature; existing jobs get zero behavior change. Minor, non-blocking note: this does introduce a small amount of duplication between the two BasicTypeDefine-building methods — an acceptable, deliberate tradeoff for behavioral isolation, not a defect.
  • Issue 3 (Medium, "missing doc comments on trickiest new logic") — confirmed fixed. hasSameRelationSchema/hasSameColumnDefinition (renamed, see Issue 4), hasSameCatalogSchema, PostgresRelationSchemaRecord.create(...), dispatchRelationSchemaChange, hasSameBaselineSchema, and both lastRelationSchemas/relationSchemaBaseline fields all now carry explanatory comments describing what each dedup layer protects against (in-memory per-task suppression vs. checkpoint-restore suppression across restarts) and their threading assumptions (single Debezium reader thread). This is exactly the "why does this dedup exist" context a future maintainer touching restore behavior needs.
  • Issue 4 (Low, "hasSameSchema name reused with different semantics") — confirmed fixed. Renamed to RelationAwarePostgresSchema.hasSameRelationSchema (raw Debezium tables, includes PK comparison) vs. PostgresRelationSchemaChangeResolver.hasSameCatalogSchema (SeaTunnel-converted columns only). All call sites (dispatchRelationSchemaChange, hasSameBaselineSchema) were updated consistently; no stale reference to the old name remains anywhere in the diff.

New, minor observation from this fresh pass (not present in the previous round — flagging for completeness, not a blocker): PostgresSourceConfigFactory.java moved props.setProperty("include.schema.changes", ...) to run after props.putAll(dbzProperties) (the debezium.* pass-through properties), specifically so the new schema-changes.enabled flag is authoritative. Before this PR, an advanced user setting debezium.include.schema.changes = true as a raw pass-through property could override the hardcoded false. That override is now unconditionally discarded regardless of the new option's value. In practice this was very likely an inert knob before this PR (SeaTunnel's PostgreSQL deserializer didn't recognize any Postgres schema-change record shape until this PR added it), so I don't believe this breaks any real working job — flagging only as a documentation nicety, not a functional regression.

1.2 Compatibility Impact

Fully compatible. (Revised from "Partially incompatible" in my previous round — that assessment is now stale, since the fix in 60f0c64c11 for Issue 2 removed the one unconditional side effect I had flagged.)

  • The feature is strictly opt-in: schema-changes.enabled defaults to false, reproducing the previously-hardcoded include.schema.changes=false Debezium property. With it disabled, databaseSchema.setRelationChangeListener(...) is never called (gated by connectorConfig.isSchemaChangesHistoryEnabled()), so RelationAwarePostgresSchema.applySchemaChangesForTable behaves identically to the old PostgresSchema.
  • PostgresObjectUtils.newSchema's return type changing from PostgresSchema to RelationAwarePostgresSchema is a compatible covariant change.
  • The shared convertFromColumn snapshot-chunking path is now provably untouched by the schema-evolution type-conversion changes (see Issue 2 above).
  • No checkpoint/savepoint serialization format changes; the restore mechanism reuses pre-existing, already-shipped IncrementalSplit.getCheckpointTables() / BaseChangeStreamTableSourceFactory.mergeTableStruct infrastructure.

1.3 Performance / Side-Effect Analysis

  • dispatchRelationSchemaChange only runs when schema-changes.enabled=true; for disabled jobs there is zero added overhead (listener not registered).
  • When enabled, the added work per RELATION message is a HashMap.put + a bounded linear scan over relationSchemaBaseline/column comparison — bounded by table/column count, not a hot-row-level path (RELATION messages are far rarer than DML).
  • lastRelationSchemas is a HashMap bounded by distinct-table cardinality, cleared per configure() call — no leak risk under normal table counts.

1.4 Error Handling and Logging

No unresolved High/Medium issues remain from this fresh pass; all four issues from the previous round are verified fixed in commit 60f0c64c11 (see 1.1 for the by-issue verification). No new blocking issues found.

2. Code Quality Assessment

2.1 Coding Standards

All previously-flagged missing doc comments are now present on the new dedup/dispatch logic and the two renamed hasSame* helpers. New methods and fields follow the module's existing conventions (matches the sibling MySQL/Oracle/SQLServer SchemaChangeResolver implementations).

2.2 Test Coverage and Test Stability

  • Unit tests (PostgresRelationSchemaChangeResolverTest): deterministic, no Thread.sleep, no shared mutable static state. Covers the happy path (multi-column ADD), no-op path, unsupported-change path, and — new in this commit — the "cached table missing" path (shouldRejectRelationWhenCachedTableIsMissing), closing the coverage gap I flagged in the previous round.
  • E2E test (PostgresCDCIT.testAddColumnSchemaEvolutionWithRestore): uses Awaitility.await().atMost(60000, MILLISECONDS).untilAsserted(...) throughout, no raw Thread.sleep. Genuinely exercises the checkpoint-restore scenario (savepoint → source-only ADD COLUMN → restore → assert row content and sink-side information_schema.columns data type via the new getColumnDataTypeQuery helper). The finally block now also drops the added test column (dropFieldIfExists) after clearing rows, correctly avoiding leaving mutated schema state for subsequent test runs — an improvement over the previous round. I confirmed the modified postgrescdc_to_postgres_test_add_Filed.conf is used only by this one test method (both references at lines 952 and 989 are within the same test), so switching its decoding.plugin.name to pgoutput and adding schema-changes.enabled=true carries no risk to unrelated tests.
  • Rating: Stable. No flaky patterns found. Coverage gap from the previous round is closed.

2.3 Documentation Updates

docs/en/connectors/source/PostgreSQL-CDC.md and docs/zh/... both add the three new options and a worked example. Documented behavior matches the source: the "row change after DDL needed to observe the change" limitation and the "job fails before processing rows with that schema" behavior for unsupported changes both match the traced code paths.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix / long-term solution. Rather than inventing a parallel schema-evolution mechanism, this plugs into the existing generic SchemaChangeResolver / TableSchemaChangeEventDispatcher / SupportSchemaEvolution / checkpoint-restore infrastructure already proven by MySQL/Oracle/SQLServer CDC — confirmed in this pass by tracing that BaseChangeStreamTableSourceFactory and mergeTableStruct are the exact same pre-existing classes/methods MySQL and Oracle already use, not new parallel implementations.

3.2 Maintainability

Good. The follow-up commit specifically improved maintainability by adding the missing comments and disambiguating the two hasSame* helper names — both were the weakest points in the previous round and are now addressed.

3.3 Extensibility

The resolver's support()/resolve() structure and SchemaChangeType.ADD_COLUMN-only supports() declaration make it straightforward to extend to other change types later without touching the dispatch plumbing.

3.4 Historical-Version Compatibility

Verified: default-disabled feature flag reproduces the prior hardcoded Debezium property value exactly, so existing running/checkpointed jobs are unaffected. The one real compatibility caveat from the previous round (unconditional Types.OTHER fallback change) is now fully resolved. No checkpoint/savepoint serialization format changes.

4. Issue Summary

# Issue Location Severity
- All 4 issues from the previous review (table-lookup fail-fast, unconditional type-conversion side effect, missing doc comments, hasSameSchema naming collision) see 1.1 for per-issue verification Resolved

No new blocking issues found in this fresh full re-review.

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers — must be fixed: none. All previously-identified blockers and non-blocking recommendations were addressed in 60f0c64c11, and I independently re-verified each fix at the source level (not just trusting the commit message) rather than assuming the previous review's conclusions still hold.
  2. Recommended fixes — non-blocking: none new. (Optional, very low priority: the PR description could mention that a raw debezium.include.schema.changes pass-through override is now shadowed by the new schema-changes.enabled option — see the note at the end of 1.1 — but I could not find any realistic scenario where this changes an existing job's actual behavior.)

Overall assessment: this is a substantial, carefully-designed feature that correctly reuses SeaTunnel's existing generic CDC schema-evolution and checkpoint-restore machinery, verified end to end on this fresh pass including the race-condition and no-restart-required questions specific to this re-review. The E2E test proves the highest-value scenario (savepoint restore across an ADD COLUMN, including a positive assertion on the evolved sink column's actual data type). The follow-up commit closes every gap from the previous round cleanly and minimally, without introducing new scope. I'm satisfied this is ready to merge pending green CI.

Note on CI: please confirm CI is fully green on this exact head commit (60f0c64c11) before merging; this review remains source-level analysis per project convention that all compile/test verification for Apache SeaTunnel PRs is CI-authoritative.

@SEZ9 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I reviewed the latest head 60f0c64c117e.

What this PR fixes

  • User pain: PostgreSQL CDC jobs using pgoutput silently kept emitting rows against the schema captured at startup because logical replication never ships DDL text, so an ALTER TABLE ... ADD COLUMN on the source left downstream sinks stale or, worse, misaligned with new row payloads.
  • Fix approach: intercept pgoutput RELATION messages via a new RelationAwarePostgresSchema (returned from PostgresObjectUtils.newSchema), diff the refreshed Debezium Table against SeaTunnel's authoritative CatalogTable, emit a synthetic AlterTableAddColumnEvent before the triggering DML, and fail fast via SchemaEvolutionException (now rethrown in the shared deserializer) for any non-ADD-COLUMN row-schema change.
  • One-line summary: the feature works end-to-end for appended ADD COLUMN with docs, unit and E2E coverage, but several shared-path changes (the base deserializer rethrow, the SUPPORT_SCHEMA_CHANGE_EVENT_KEY_NAME addition, and the newSchema return-type change) affect other CDC connectors — notably Opengauss which overlays these classes — and the mutate-then-publish ordering plus the non-volatile listener field need hardening before merge.

Runtime chain I rechecked

pgoutput RELATION message (Debezium streaming thread)
  PgOutputMessageDecoder.handleRelationMessage() -> PostgresSchema.applySchemaChangesForTable()
    RelationAwarePostgresSchema.applySchemaChangesForTable(relationId, table)  RelationAwarePostgresSchema.java:56
      super.applySchemaChangesForTable(relationId, table)   // Debezium in-memory schema mutated FIRST  RelationAwarePostgresSchema.java:60
      relationChangeListener.accept(table)                  // plain field, set post-construction via setRelationChangeListener()  RelationAwarePostgresSchema.java:44
        -> listener enqueues synthetic schema-change SourceRecord keyed io.debezium.connector.postgresql.SchemaChangeKey
           SourceRecordUtils.isSchemaChangeEvent() matches via SUPPORT_SCHEMA_CHANGE_EVENT_KEY_NAME  SourceRecordUtils.java:50-55
  SeaTunnelRowDebeziumDeserializeSchema.deserialize()
    -> deserializeSchemaChangeRecord(record)  SeaTunnelRowDebeziumDeserializeSchema.java:130
      schemaChangeResolver.resolve(record, tables)   // Postgres resolver diffs RELATION Table vs CatalogTable
      catch (SchemaEvolutionException e) { throw e; }  // fail-fast path, shared by ALL CDC connectors  SeaTunnelRowDebeziumDeserializeSchema.java:137-141
      catch (Exception e) { log.warn(...); return; }   // wrapped/unclassified failures still swallowed AFTER Debezium schema was mutated  SeaTunnelRowDebeziumDeserializeSchema.java:142-145
    -> AlterTableAddColumnEvent dispatched through TableSchemaChangeEventDispatcher to sink schema-evolution/checkpoint path

Findings

Issue 1: Non-SchemaEvolutionException failures in the Postgres resolver are still swallowed after Debezium's in-memory schema was already mutated, causing silent schema divergence instead of the documented fail-fast

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:141
  • Why it matters: - Root cause: deserializeSchemaChangeRecord rethrows only SchemaEvolutionException; every other exception from schemaChangeResolver.resolve(record, tables) falls through to the pre-existing generic catch that logs "Failed to resolve schemaChangeEvent, just skip." and returns. For Postgres, by the time the synthetic schema record reaches this method, RelationAwarePostgresSchema.applySchemaChangesForTable has already committed the new relation into Debezium's internal schema via super.applySchemaChangesForTable.
  • Impact: if the Postgres resolver fails with any unclassified RuntimeException (e.g., a type-mapping NPE), the schema-change record is dropped while Debezium's schema already reflects the new column. Subsequent DML for that table is deserialized against the stale SeaTunnel schema, so the new column's data is silently lost — exactly the divergence this PR's fail-fast contract is meant to prevent, and pgoutput will not resend the RELATION message within the same session.
  • Suggested fix: wrap all unexpected failures inside PostgresRelationSchemaChangeResolver.resolve into SchemaEvolutionException so they reach the rethrow path, or record the table as having an unresolved pending schema change and fail its next DML.
  • Evidence: seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:141 throw e;; seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:54-55 Table previousTable = tableFor(table.id()); super.applySchemaChangesForTable(relationId, table);; seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:138 // A resolver uses SchemaEvolutionException only when continuing would make the
  • Suggested fix: Rethrowing only SchemaEvolutionException leaves a dangerous gap for Postgres: any other RuntimeException from PostgresRelationSchemaChangeResolver.resolve (e.g., a type-mapping NPE) hits the generic catch below and is skipped — but Debezium's in-memory schema was already mutated by RelationAwarePostgresSchema.applySchemaChangesForTable, so subsequent DML is deserialized with a stale SeaTunnel schema and the new column's data is silently dropped, contradicting the documented fail-fast. Please wrap all unexpected failures inside the Postgres resolver into SchemaEvolutionException (or mark the table as having an unresolved pending schema and fail its next DML).
  • Severity: Medium

Issue 2: Rethrowing SchemaEvolutionException in the shared CDC base deserializer changes failure semantics for every Debezium-based connector, not just PostgreSQL

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:137
  • Why it matters: - Root cause: SeaTunnelRowDebeziumDeserializeSchema.deserializeSchemaChangeRecord is shared by MySQL, Oracle, SqlServer, Opengauss and Postgres CDC sources. Before this PR every exception thrown by schemaChangeResolver.resolve(record, tables) was logged and the record skipped; the new catch (SchemaEvolutionException e) { throw e; } block turns that into a hard job failure for any resolver on any connector that throws this exception type.
  • Impact: an existing MySQL/Oracle/SqlServer resolver that surfaces SchemaEvolutionException would now fail the job where it previously logged and continued, and on restore the job would replay the same schema-change record and crash-loop, with no way for the user to skip past it.
  • Suggested fix: confirm that no existing resolver can throw SchemaEvolutionException today, and scope the new fail-fast contract explicitly — e.g., a Postgres-specific exception type or an opt-in flag on the resolver — and document the contract on the SchemaChangeResolver interface so future resolver authors know that throwing this type fails the job.
  • Evidence: seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:137 } catch (SchemaEvolutionException e) {; seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:141 throw e;; seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializeSchema.java:138-140 // A resolver uses SchemaEvolutionException only when continuing would make the // produced row schema diverge from the source relation. Keep generic parser failures // backward-compatible, but fail fast for an explicitly classified schema error.
  • Suggested fix: This class is shared by all Debezium-based CDC sources (MySQL, Oracle, SqlServer, Opengauss), so rethrowing SchemaEvolutionException here changes the failure semantics for every connector, not only PostgreSQL. Previously any resolver exception was logged and skipped; now a resolver that throws this type will hard-fail the job and, on restore, crash-loop on the same replayed record. Please confirm none of the existing resolvers can surface SchemaEvolutionException today, and consider scoping the fail-fast contract (e.g. a Postgres-specific exception, or an explicit opt-in flag on the resolver) plus documenting it on the SchemaChangeResolver interface.
  • Severity: Medium

Issue 3: RelationAwarePostgresSchema.relationChangeListener is a plain mutable field set via setter after construction — no volatile/final guarantee for the Debezium streaming thread that reads it

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:33
  • Why it matters: - Root cause: relationChangeListener is declared as a plain field and injected through setRelationChangeListener(...) after the schema object is created in PostgresObjectUtils.newSchema(...). The reader is applySchemaChangesForTable(...), invoked by Debezium's pgoutput streaming thread, while the writer is the fetch-task setup path — a cross-thread publication without a memory barrier.
  • Impact: if the listener registration does not strictly happen-before the streaming thread's read, the streaming thread may observe a stale null and silently skip forwarding a RELATION change. Because super.applySchemaChangesForTable has already updated Debezium's in-memory table by that point, the ADD COLUMN will never be re-detected within the session.
  • Suggested fix: declare the field volatile, or better, inject the listener via the constructor to get final-field publication semantics; additionally null-guard the listener call with a WARN log (or buffer the change) so an early RELATION message is not lost without a trace.
  • Evidence: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:44-46 public void setRelationChangeListener(Consumer<Table> relationChangeListener) { this.relationChangeListener = relationChangeListener; }; seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:53-55 public void applySchemaChangesForTable(int relationId, Table table) { Table previousTable = tableFor(table.id()); super.applySchemaChangesForTable(relationId, table);; seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:44 public void setRelationChangeListener(Consumer<Table> relationChangeListener) {
  • Suggested fix: relationChangeListener is written by the fetch-task setup thread via setRelationChangeListener but read by Debezium's pgoutput streaming thread inside applySchemaChangesForTable. Without volatile (or constructor injection with final-field semantics) the streaming thread may observe a stale null and silently drop a RELATION change — and since super.applySchemaChangesForTable has already updated the in-memory table, the ADD COLUMN will never be re-detected. Please make this field volatile (or pass it via the constructor) and null-guard with a WARN/buffer so an early RELATION message is not lost.
  • Severity: Medium

Issue 4: Debezium's in-memory schema is mutated before the RELATION change is published to SeaTunnel; a failure between the two steps silently loses the ADD COLUMN event for the rest of the session

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:55
  • Why it matters: - Root cause: in RelationAwarePostgresSchema.applySchemaChangesForTable, super.applySchemaChangesForTable(relationId, table) is invoked first (per the javadoc, "Updates Debezium's schema first and then publishes a synthetic schema record"), and only afterwards is the change forwarded through relationChangeListener.
  • Impact: pgoutput sends a RELATION message for a table at most once per replication session unless the definition changes again. If the listener invocation fails or the synthetic record is never emitted, Debezium's cache already holds the new definition, so the before/after diff will never re-fire — the ADD COLUMN detection is permanently lost for the session while row payloads already carry the new column.
  • Suggested fix: invoke the listener before committing the change to Debezium's cache, or ensure any listener exception propagates so the task fails and re-detects the change on restore; the exception must not be swallowed at this point.
  • Evidence: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:54 Table previousTable = tableFor(table.id());; seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:55 super.applySchemaChangesForTable(relationId, table);
  • Suggested fix: Since pgoutput sends a RELATION message for a table only once per replication session (until the definition changes again), calling super.applySchemaChangesForTable(...) before forwarding the change to the listener creates a window where a listener failure permanently loses the ADD COLUMN detection for this session: Debezium's cache is already updated, so the diff will never re-fire. Please either invoke the listener before mutating the cache, or ensure any listener exception propagates so the task fails and re-detects on restore — the exception must not be swallowed here.
  • Severity: Medium

Issue 5: Unconditional replacement of PostgresSchema with RelationAwarePostgresSchema plus late listener wiring creates a window where the first RELATION message after a DDL can be consumed without being forwarded

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/PostgresObjectUtils.java:53
  • Why it matters: - Root cause: PostgresObjectUtils.newSchema now always constructs RelationAwarePostgresSchema, and the listener is attached later via a setter. pgoutput sends the RELATION message for a table exactly once before the first row change after (re)connect or after a DDL; applySchemaChangesForTable first reads tableFor(table.id()) and then commits the new definition via super.applySchemaChangesForTable(relationId, table) regardless of whether a listener is attached.
  • Impact: if a RELATION message arrives before setRelationChangeListener is called, the new definition is committed into Debezium's in-memory schema without ever reaching SeaTunnel, and pgoutput will not resend it — the ADD COLUMN event is lost for the session.
  • Suggested fix: inject the listener via the constructor so it is guaranteed to be present before the streaming engine starts, or buffer relation changes observed while the listener is null and replay them once a listener is registered.
  • Evidence: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/PostgresObjectUtils.java:53-54 RelationAwarePostgresSchema schema = new RelationAwarePostgresSchema(; seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/RelationAwarePostgresSchema.java:44-46 public void setRelationChangeListener(Consumer<Table> relationChangeListener) { this.relationChangeListener = relationChangeListener; }
  • Suggested fix: newSchema now always builds RelationAwarePostgresSchema, but the listener is wired later through a setter. pgoutput sends a table's RELATION message only once before the first row change after a DDL/reconnect, so any RELATION processed before setRelationChangeListener is called gets committed into Debezium's in-memory schema (super.applySchemaChangesForTable) without ever reaching SeaTunnel — and it won't be resent. Please inject the listener via the constructor before the streaming engine starts, or buffer changes seen while the listener is null and replay them on registration.
  • Severity: Medium

Issue 6: Docs do not state what happens when schema-changes.enabled=true is combined with a non-pgoutput decoding plugin

  • Location: docs/en/connectors/source/PostgreSQL-CDC.md:119
  • Why it matters: - Root cause: the new option row in docs/en/connectors/source/PostgreSQL-CDC.md:119 says the option "requires decoding.plugin.name = "pgoutput"", but neither the table row nor the new "Schema evolution for ADD COLUMN" section explains how that requirement is enforced.
  • Impact: users running the default decoderbufs (or wal2json) plugin who set schema-changes.enabled = true cannot tell from the docs whether the job fails fast at startup or silently never emits schema events — a silent no-op is hard to diagnose because the job appears healthy while schema changes go undetected. The ZH page (docs/zh/connectors/source/PostgreSQL-CDC.md:117) has the same gap.
  • Suggested fix: add one sentence to both the EN and ZH pages describing the actual enforcement behavior (matching what PostgresIncrementalSourceFactory does when the plugin is not pgoutput).
  • Evidence: docs/zh/connectors/source/PostgreSQL-CDC.md:117 | schema-changes.enabled | Boolean | 否 | false | 启用 Schema 演进事件。PostgreSQL CDC 当前仅支持 ADD COLUMN,并且要求 decoding.plugin.name = "pgoutput"。...; docs/en/connectors/source/PostgreSQL-CDC.md:120 | schema-changes.include | List | No | - | Only the listed schema change event types are sent downstream when schema evolution is enabled. For the currently supported operation, use add.column(or theupdate.columns group alias). Empty means all supported types are eligible. |; docs/zh/connectors/source/PostgreSQL-CDC.md:118 | schema-changes.include | List | 否 | - | Schema 演进启用后,仅向下游发送列出的事件类型。当前支持的操作请使用 add.column(或分组别名 update.columns)。为空表示允许全部受支持的类型。 |
  • Suggested fix: The row says this option "requires decoding.plugin.name = "pgoutput"", but doesn't say what happens if a user enables it with the default decoderbufs plugin — fail-fast validation error or silently no schema events? Please add one sentence describing the actual enforcement (matching what PostgresIncrementalSourceFactory does), and mirror it in the ZH page, so users don't hit a silent no-op.
  • Severity: Medium

Issue 7: PostgresObjectUtils.newSchema return-type change (PostgresSchema → RelationAwarePostgresSchema) is binary-incompatible and risks breaking the Opengauss CDC connector that overlays io.debezium.connector.postgresql classes

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/PostgresObjectUtils.java:46
  • Why it matters: - Root cause: the binary method descriptor of newSchema changed because Java encodes the return type in it; any class compiled against the old PostgresSchema return type will hit NoSuchMethodError at runtime if it links against the new jar (and vice versa).
  • Impact: connector-cdc-opengauss depends on connector-cdc-postgres and ships its own copies of several io.debezium.connector.postgresql.* classes in the same package; depending on classloader/overlay ordering, an Opengauss job could resolve a caller compiled against the old signature and fail at link time rather than at build time.
  • Suggested fix: keep the declared return type as PostgresSchema and downcast where the setter is needed (e.g., in PostgresSourceFetchTaskContext), or add an overload so callers compiled against the old signature continue to link; verify the Opengauss E2E suite passes against this change.
  • Evidence: seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/PostgresObjectUtils.java:53 RelationAwarePostgresSchema schema =; seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/io/debezium/connector/postgresql/PostgresObjectUtils.java:54 new RelationAwarePostgresSchema(
  • Suggested fix: Changing the return type of newSchema from PostgresSchema to RelationAwarePostgresSchema changes the method's binary signature. connector-cdc-opengauss reuses/overlays io.debezium.connector.postgresql classes from this module, so please verify it still links correctly (Opengauss E2E). A safer shape is to keep the declared return type as PostgresSchema and downcast in PostgresSourceFetchTaskContext, or add an overload, so external overlays compiled against the old signature don't hit NoSuchMethodError.
  • Severity: Medium

Issue 8: Adding io.debezium.connector.postgresql.SchemaChangeKey to the shared SUPPORT_SCHEMA_CHANGE_EVENT_KEY_NAME list reclassifies such records globally, including when schema evolution is disabled

  • Location: seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/utils/SourceRecordUtils.java:55
  • Why it matters: - Root cause: SourceRecordUtils.SUPPORT_SCHEMA_CHANGE_EVENT_KEY_NAME lives in connector-cdc-base and drives isSchemaChangeEvent(...) for every CDC connector; the Postgres key is now matched unconditionally, regardless of schema-changes.enabled.
  • Impact: any record carrying this key is routed into deserializeSchemaChangeRecord, where a null schemaChangeResolver means the record is silently dropped instead of surfacing as data or an error. This also applies to Opengauss CDC, which reuses the Postgres pgoutput stack.
  • Suggested fix: confirm the synthetic schema record emission is strictly gated on the schema-evolution option (i.e., no listener is registered when it is disabled), and add a log when a schema-change-keyed record arrives with no resolver so silent drops are diagnosable.
  • Evidence: seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/utils/SourceRecordUtils.java:55 "io.debezium.connector.postgresql.SchemaChangeKey");
  • Suggested fix: This key is now matched globally (also for Opengauss CDC which reuses the Postgres pgoutput stack), independent of schema-changes.enabled. Records with this key and a null resolver are silently dropped in deserializeSchemaChangeRecord. Please confirm the synthetic schema record emission is strictly gated on the schema-evolution option (no listener registered when disabled), and consider logging when a schema-change-keyed record is received with no resolver so drops are diagnosable.
  • Severity: Low

Review conclusion

Conclusion: final approval remains pending on the previous comments

2. Remaining follow-ups

  • Issue 1: Non-SchemaEvolutionException failures in the Postgres resolver are still swallowed after Debezium's in-memory schema was already mutated, causing silent schema divergence instead of the documented fail-fast
  • Issue 2: Rethrowing SchemaEvolutionException in the shared CDC base deserializer changes failure semantics for every Debezium-based connector, not just PostgreSQL
  • Issue 3: RelationAwarePostgresSchema.relationChangeListener is a plain mutable field set via setter after construction — no volatile/final guarantee for the Debezium streaming thread that reads it
  • Issue 4: Debezium's in-memory schema is mutated before the RELATION change is published to SeaTunnel; a failure between the two steps silently loses the ADD COLUMN event for the rest of the session
  • Issue 5: Unconditional replacement of PostgresSchema with RelationAwarePostgresSchema plus late listener wiring creates a window where the first RELATION message after a DDL can be consumed without being forwarded
  • Issue 6: Docs do not state what happens when schema-changes.enabled=true is combined with a non-pgoutput decoding plugin
  • Issue 7: PostgresObjectUtils.newSchema return-type change (PostgresSchema → RelationAwarePostgresSchema) is binary-incompatible and risks breaking the Opengauss CDC connector that overlays io.debezium.connector.postgresql classes
  • Issue 8: Adding io.debezium.connector.postgresql.SchemaChangeKey to the shared SUPPORT_SCHEMA_CHANGE_EVENT_KEY_NAME list reclassifies such records globally, including when schema evolution is disabled

Thanks for the updates so far. Happy to discuss the remaining points.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the very thorough follow-up, @SEZ9 — I re-checked every point against the current head (60f0c64c117e) and you caught something my approval missed. Sorry for that; converting my prior APPROVED back to a blocking review.

Issue 1 is a genuine, verified defect and I'm treating it as the blocker.

PostgresRelationSchemaChangeResolver.resolveAddedColumns calls convertToSeaTunnelColumn(after, i) → PostgresTypeConverter.INSTANCE.convert(PostgresTypeUtils.convertRelationColumnToTypeDefine(...)) for every added column, and that call is not wrapped in a SchemaEvolutionException/SchemaValidationException. Only the two explicit throw unsupportedChange(...) / throw invalidRelationRecord(...) paths are classified — a type-mapping failure on an unmapped/unusual PG type (arrays, custom types, etc.) surfaces as a raw RuntimeException.

That lands in SeaTunnelRowDebeziumDeserializeSchema.deserializeSchemaChangeRecord's generic catch (Exception e) (log + return, SeaTunnelRowDebeziumDeserializeSchema.java:142-145), not the fail-fast catch (SchemaEvolutionException e) { throw e; } path added by this PR (:137-141). By the time this resolver runs, RelationAwarePostgresSchema.applySchemaChangesForTable (RelationAwarePostgresSchema.java:55) has already committed the new relation into Debezium's in-memory schema — the super.applySchemaChangesForTable(...) call happens before relationChangeListener.accept(table). So the exact failure mode this PR exists to prevent (silent divergence between Debezium's schema and SeaTunnel's CatalogTable, with the new column's data lost) is still reachable through an un-classified exception in the type-conversion step. I confirmed the ordering and the missing wrap directly in the current source.

I also verified Issues 3/4/5 are the same root cause from different angles — relationChangeListener is a plain (non-volatile) field set post-construction via setRelationChangeListener, and it's genuinely only wired when isSchemaChangesHistoryEnabled() is true, confirmed at PostgresSourceFetchTaskContext.java:263-264. Given pgoutput sends a table's RELATION message at most once per session, I agree these should be hardened together with Issue 1 rather than treated as separate follow-ups.

On the others: Issue 2 — confirmed none of MySqlSchemaChangeResolver / OracleSchemaChangeResolver / SqlServerSchemaChangeResolver currently throw SchemaEvolutionException, so there's no active regression today, but agreed the contract should be documented on SchemaChangeResolver so it stays that way. Issue 7 — confirmed newSchema's return type did change and Opengauss does overlay two classes in the same io.debezium.connector.postgresql package, but it doesn't override PostgresObjectUtils/RelationAwarePostgresSchema/PostgresSourceFetchTaskContext, and the modules are built together in the same reactor, so I'd rate the practical risk lower than Medium in normal release flow — still worth a defensive Opengauss E2E check before merge. Issues 6 and 8 read correctly as non-blocking polish.

Revised conclusion: Issue 1 (and the related 3/4/5 ordering hardening) needs a real fix before merge — please wrap/classify resolver failures (including the type-conversion path) so any unexpected exception during schema-change resolution is treated as fail-fast rather than silently skipped after Debezium's schema has already moved. Happy to re-review as soon as that's in.

@github-actions github-actions Bot removed the reviewed label Aug 26, 2026

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fast follow-up, @dybyte — I reviewed the new commit c7439f83e25 ("Fail fast on PostgreSQL schema resolution errors") and did a complete fresh re-review of the current head from scratch (not the incremental diff, and not assuming my own prior conclusions still hold). One correction up front: on this pass I traced the actual thread-submission call chain more rigorously than in my previous CHANGES_REQUESTED, and it shows Issues 3/4/5 from @SEZ9's review — which I endorsed as blocking "hardening" alongside Issue 1 — are not actually races. Details below, with evidence, since I don't want to just take back a position without justification.

What Problem Does This PR Solve?

  • User pain point: PostgreSQL's pgoutput logical replication never carries DDL text, so unlike MySQL/Oracle/SQLServer CDC, the connector previously could not propagate ALTER TABLE ... ADD COLUMN to downstream sinks — jobs kept deserializing rows against the schema captured at startup.
  • Fix approach: subclass Debezium's PostgresSchema to intercept RELATION messages, diff against SeaTunnel's tracked CatalogTable (including the checkpoint-restored one on restart), synthesize a schema-change record, and reuse the generic SchemaChangeResolver/TableSchemaChangeEventDispatcher machinery already used by MySQL/Oracle/SQLServer.
  • One-sentence summary: the feature is opt-in, correctly reuses existing generic schema-evolution/checkpoint infrastructure, and this follow-up commit closes the one genuine fail-fast gap from the previous round.

1. Code Change Review

1.1 Core Logic Analysis

Issue 1 fix (High, from previous round) — verified fixed and correctly tested.
PostgresRelationSchemaChangeResolver.resolve() (seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/.../PostgresRelationSchemaChangeResolver.java:57-89) now wraps the whole body in try { ... } catch (SchemaEvolutionException e) { throw e; } catch (Exception e) { throw new SchemaEvolutionException(SchemaEvolutionErrorCode.INVALID_SCHEMA_STRUCTURE, ..., e); }. This means a previously-unclassified failure in convertToSeaTunnelColumn → PostgresTypeConverter.convert(...) (e.g. an unmapped PG type) is now reclassified as SchemaEvolutionException, which SeaTunnelRowDebeziumDeserializeSchema's existing catch (SchemaEvolutionException e) { throw e; } (unchanged, :137-141) correctly rethrows instead of silently absorbing via the generic catch (Exception e) { log.warn(...); return; } fallback. The new unit test shouldFailFastWhenAddedColumnTypeCannotBeConverted genuinely exercises this: it builds a uuid[] array column, which I confirmed falls through PostgresTypeConverter.convert()'s named case list to default: with sqlType == Types.ARRAY (not Types.OTHER), so it reaches the throwing branch, not the Types.OTHER → STRING fallback — this is a real repro of the old bug, not a shallow assertion. Also good: the interface SchemaChangeResolver.resolve() now carries a javadoc contract explaining when implementations must throw SchemaEvolutionException vs. let generic exceptions be treated as recoverable — this documents exactly what @SEZ9 asked for in their Issue 2.

Issues 3/4/5 (Medium, previous round) — re-traced end to end, and I no longer believe these are real defects.
I followed the actual call chain from split assignment to WAL decoding:

IncrementalSourceStreamFetcher.submitTask(fetchTask)                         [caller thread]
  taskContext.configure(currentIncrementalSplit)
    -> databaseSchema.setRelationChangeListener(this::dispatchRelationSchemaChange)   [write]
  executorService.submit(() -> streamFetchTask.execute(taskContext))          [single-thread executor, "debezium-reader-N"]
    -> PostgresWalFetchTask.execute() builds & runs PostgresStreamingChangeEventSource.execute(...)
       (blocks on this same executor thread, decoding the WAL stream in-line)
    -> RelationAwarePostgresSchema.applySchemaChangesForTable(...)
       -> relationChangeListener.accept(table)                                [read]

setRelationChangeListener is called synchronously in configure(), strictly before executorService.submit(...) hands the task to the single-thread executor. Per the java.util.concurrent memory-consistency guarantee ("actions in a thread prior to submitting a Runnable to an Executor happen-before its execution begins"), the write is guaranteed visible to the executor thread without needing volatile — so Issue 3 (non-volatile field) isn't a real visibility bug, and Issue 5 ("RELATION could arrive before the listener is wired") can't happen either, since the listener is wired before the task is even submitted, let alone before the WAL decoder starts running. On Issue 4 (schema mutated before publish; "permanently lost if publish fails"): dispatchRelationSchemaChange's only failure mode is queue.enqueue throwing InterruptedException, which is caught and rethrown as DebeziumException, which fails the whole streaming task and forces a restart. On restart, configure() rebuilds databaseSchema from scratch and PostgresWalFetchTask.execute() opens a brand-new replication connection/session — and pgoutput sends a table's RELATION message once per session, so the "lost" RELATION is simply resent on the new session. I don't see a path where the event is silently and permanently dropped.
I'm flagging this correction explicitly rather than quietly dropping it, since I was the one who escalated it to blocking status in my previous review without tracing submitTask()/ExecutorService semantics that carefully.

Compatibility / normal-path check (per this round's specific focus): schema-changes.enabled still defaults to false; setRelationChangeListener is only called when connectorConfig.isSchemaChangesHistoryEnabled() (PostgresSourceFetchTaskContext.java:236-238), so resolve() — including this commit's new try/catch — is unreachable for any job that hasn't opted in. Existing non-schema-evolution PostgreSQL CDC jobs get zero behavior change from this commit.

Checkpoint/restore check: unchanged by this commit. relationSchemaBaseline (built from IncrementalSplit.getCheckpointTables() on restore, or fresh discovery otherwise) and the lastRelationSchemas in-task dedup are untouched, so a checkpoint taken before an ADD COLUMN still restores and dedupes correctly, matching my analysis from the previous two rounds.

1.2 Compatibility Impact

Fully compatible — no change to defaults, serialization, or checkpoint format; the new try/catch only changes behavior on a path that was already exclusive to schema-changes.enabled=true.

1.3 Performance / Side-Effect Analysis

Negligible — one additional try/catch around already-executing resolver logic, only reachable when the feature is enabled.

1.4 Error Handling and Logging

No open High/Medium issues from this commit. Two pre-existing, non-blocking items remain untouched by this commit (carried from @SEZ9's review, both already correctly rated non-blocking in my previous comment):

  • Issue 6 (Medium): docs still don't state what happens if schema-changes.enabled=true is combined with a non-pgoutput decoding plugin (fail-fast vs. silent no-op) — docs/en/connectors/source/PostgreSQL-CDC.md:119, docs/zh/...:117.
  • Issue 7 (Medium→practically Low, per my previous analysis): PostgresObjectUtils.newSchema's return-type change to RelationAwarePostgresSchema is binary-incompatible; connector-cdc-opengauss overlays classes in the same io.debezium.connector.postgresql package but doesn't override the three classes involved, and both modules build in the same reactor, so risk is low — a defensive Opengauss E2E check before merge is still worthwhile.
  • Issue 8 (Low): SUPPORT_SCHEMA_CHANGE_EVENT_KEY_NAME now matches the Postgres schema-change key globally (also affecting Opengauss), independent of schema-changes.enabled; a record with this key and no resolver registered is silently dropped. Consider a diagnostic log for that case.

2. Code Quality Assessment

2.1 Coding Standards

The new try/catch and interface javadoc are clear and consistent with the rest of the resolver. Good.

2.2 Test Coverage and Test Stability

New unit test shouldFailFastWhenAddedColumnTypeCannotBeConverted is deterministic, no sleeps, no shared static state, and genuinely reproduces the previously-unclassified exception (verified against PostgresTypeConverter's switch/default logic, not just asserted). Rating: Stable.

2.3 Documentation Updates

No doc changes in this commit; Issue 6 above remains open as a non-blocking documentation gap from the original PR.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise, minimal fix — a targeted try/catch plus an interface-level contract comment, scoped exactly to the resolver that needed it.

3.2 Maintainability

Good; the new javadoc on SchemaChangeResolver.resolve() makes the fail-fast contract explicit for future resolver authors (addresses @SEZ9's Issue 2 ask).

3.3 Extensibility

Unchanged from previous rounds — still a clean support()/resolve() shape.

3.4 Historical-Version Compatibility

Unaffected; default-disabled flag and checkpoint-restore mechanism are both untouched by this commit.

4. Issue Summary

# Issue Location Severity
1 Resolver failures during type conversion not classified as fail-fast PostgresRelationSchemaChangeResolver.java:57-89 Resolved (verified + tested)
3/4/5 Listener field visibility / mutate-before-publish ordering RelationAwarePostgresSchema.java, PostgresSourceFetchTaskContext.java Re-examined: not real defects (see 1.1)
6 Docs silent on non-pgoutput + schema-changes.enabled combination docs/en(zh)/connectors/source/PostgreSQL-CDC.md Medium, non-blocking
7 newSchema return-type change is binary-incompatible; low practical Opengauss risk PostgresObjectUtils.java Medium→Low, non-blocking
8 Global schema-change key match independent of feature flag SourceRecordUtils.java Low, non-blocking

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers — must be fixed: none. Issue 1 is fixed and tested; Issues 3/4/5 are not real defects once the submitTask() → ExecutorService.submit() → executor-thread call chain and pgoutput's per-session RELATION-resend semantics are traced through (see 1.1 for the full chain and JUC happens-before citation).
  2. Recommended fixes — non-blocking: Issues 6/7/8 (doc clarity, defensive Opengauss E2E check, diagnostic log for the global key-match edge case) can land as fast-follows.

Overall assessment: this is a well-integrated feature that correctly reuses SeaTunnel's existing CDC schema-evolution and checkpoint-restore infrastructure. I'm sorry for the churn across reviews on this one — between my own initial approval missing Issue 1, and then over-crediting Issues 3/4/5 as blocking without fully tracing the executor-submission ordering, this PR got bounced more than it should have. This fresh, from-scratch pass gives me confidence the remaining items are genuinely non-blocking polish, not correctness gaps.

Note on CI: at review time the "Build" check on this PR's fork run (dybyte/seatunnel) is still pending, not failed. Please confirm it's fully green on this exact head commit (c7439f83e25) before merging; this review remains source-level analysis per project convention that all compile/test verification is CI-authoritative.

@DanielLeens

Copy link
Copy Markdown
Contributor

Stale-CI-status update on this same head (c7439f83e25).

In my 2026-08-26 approval I flagged that the fork's Build check was still pending (not failed) at review time and asked for confirmation it finished green before merging. It has: current live CI on this exact head is fully green (Build, Notify test workflow, labeler all pass).

That review's conclusion was already "Ready to merge" with no blockers (Issue 1 fixed and tested; Issues 3/4/5 re-examined and found not to be real defects). CI confirmation was the only remaining open item, and it's now cleared. My conclusion remains Approve.

@davidzollo davidzollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
LGTM 🚀

@dybyte Huge thanks for your amazing contribution, this is a great beginning for PG serials connector 🌊🔥

@davidzollo
davidzollo added this pull request to the merge queue Sep 7, 2026
Merged via the queue into apache:dev with commit 8bea8c6 Sep 7, 2026
4 checks passed
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.

4 participants