Skip to content

[FLINK-38647][CDC] Improve error message for null before/after struct… - #4439

Merged
yuxiqian merged 8 commits into
apache:masterfrom
BreadS00:master
Jul 15, 2026
Merged

[FLINK-38647][CDC] Improve error message for null before/after struct…#4439
yuxiqian merged 8 commits into
apache:masterfrom
BreadS00:master

Conversation

@BreadS00

@BreadS00 BreadS00 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

When PostgreSQL table uses default REPLICA IDENTITY DEFAULT or REPLICA IDENTITY PRIMARY KEY, the logical decoding plugin (pgoutput) may not provide complete before-data for UPDATE events. This causes the before struct to be null in Debezium events, leading to an unhelpful NullPointerException.

Copilot AI 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.

Pull request overview

Improves diagnostics when Debezium before/after payload structs are unexpectedly null (common with PostgreSQL REPLICA IDENTITY DEFAULT/PRIMARY KEY), replacing an unhelpful downstream NullPointerException with a targeted message and an optional connector-specific hint.

Changes:

  • Add explicit null checks for before/after structs in DebeziumEventDeserializationSchema, throwing with a clearer message.
  • Introduce an overridable getNullBeforeDataHint() hook for connector-specific guidance.
  • Provide a PostgreSQL-specific hint suggesting REPLICA IDENTITY FULL.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-debezium/src/main/java/org/apache/flink/cdc/debezium/event/DebeziumEventDeserializationSchema.java Adds null checks for before/after and a hook for connector-specific hint text.
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-postgres/src/main/java/org/apache/flink/cdc/connectors/postgres/source/PostgresEventDeserializer.java Overrides the hint hook to provide a PostgreSQL-specific remediation suggestion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yuxiqian yuxiqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for @BreadS00's nice work, just left some minor comments.

@BreadS00
BreadS00 requested a review from yuxiqian July 13, 2026 09:19
@BreadS00

Copy link
Copy Markdown
Contributor Author

Thanks @yuxiqian for the review! Could you take another look when you have time?

@yuxiqian yuxiqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your rapid response! Just left some minor comments.

@yuxiqian

Copy link
Copy Markdown
Member

🤕 CI is failing...


Error:  Tests run: 10, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 78.403 s <<< FAILURE! - in org.apache.flink.cdc.connectors.postgres.source.PostgresPipelineITCase
Error:  org.apache.flink.cdc.connectors.postgres.source.PostgresPipelineITCase.testUpdateWithoutReplicaIdentityFullThrowsHelpfulNPE  Time elapsed: 1.15 s  <<< ERROR!
java.lang.IllegalStateException: No operators defined in streaming topology. Cannot execute.
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraphGenerator(StreamExecutionEnvironment.java:2556)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:2523)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:2514)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:2500)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:2449)
	at org.apache.flink.cdc.connectors.postgres.source.PostgresPipelineITCase.testUpdateWithoutReplicaIdentityFullThrowsHelpfulNPE(PostgresPipelineITCase.java:1255)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

@BreadS00

Copy link
Copy Markdown
Contributor Author

@yuxiqian ,thank you very much. I've adjusted the test case, it should be fine now.

@yuxiqian yuxiqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 from my side.

Would @leonardBang and @loserwang1024 like to take another look?

@leonardBang leonardBang 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 @BreadS00 for the contribution and @yuxiqian for the review, LGTM

@yuxiqian
yuxiqian merged commit be5399f into apache:master Jul 15, 2026
37 of 39 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