[FLINK-38647][CDC] Improve error message for null before/after struct… - #4439
Conversation
There was a problem hiding this comment.
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/afterstructs inDebeziumEventDeserializationSchema, 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.
|
Thanks @yuxiqian for the review! Could you take another look when you have time? |
yuxiqian
left a comment
There was a problem hiding this comment.
Thank you for your rapid response! Just left some minor comments.
|
🤕 CI is failing... |
|
@yuxiqian ,thank you very much. I've adjusted the test case, it should be fine now. |
yuxiqian
left a comment
There was a problem hiding this comment.
+1 from my side.
Would @leonardBang and @loserwang1024 like to take another look?
When PostgreSQL table uses default
REPLICA IDENTITY DEFAULTorREPLICA IDENTITY PRIMARY KEY, the logical decoding plugin (pgoutput) may not provide completebefore-datafor UPDATE events. This causes thebeforestruct to be null in Debezium events, leading to an unhelpfulNullPointerException.