[yugabyte/yugabyte-db#30391] Handle NPE in isBeforeImageEnabled when using Logical Replication#402
Open
bakul-gupta wants to merge 2 commits intomainfrom
Open
[yugabyte/yugabyte-db#30391] Handle NPE in isBeforeImageEnabled when using Logical Replication#402bakul-gupta wants to merge 2 commits intomainfrom
bakul-gupta wants to merge 2 commits intomainfrom
Conversation
Collaborator
|
Can you add a UT which would fail without your fix and validate that the fix works |
Sumukh-Phalgaonkar
requested changes
Mar 18, 2026
| || cdcStreamInfo.getOptions().get("record_type").equals(CDCRecordType.MODIFIED_COLUMNS_OLD_AND_NEW_IMAGES.name())) | ||
| || (cdcStreamInfo.getOptions().get("record_type").equals(CDCRecordType.PG_FULL.name()) | ||
| || cdcStreamInfo.getOptions().get("record_type").equals(CDCRecordType.PG_CHANGE_OLD_NEW.name())); | ||
| String recordType = cdcStreamInfo.getOptions().get("record_type"); |
Collaborator
There was a problem hiding this comment.
What happens when the user wants before image with a gRPC stream that has replication slot assiociated with it.
Collaborator
Author
There was a problem hiding this comment.
Setting the before image to true fixes the case you are talking about. And when the table has a replica identity say default then the before image is sent as null even though the flag is true as the message received does not have a before image.
b7c8279 to
f1bf36c
Compare
…g, indicating before image is enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira Link: DB-20273
Description
While validating gRPC connector support for Logical Replication (using a replication slot + publication instead of a stream created via yb-admin), the connector crashes during initialization with a NullPointerException in YBClientUtils.isBeforeImageEnabled().
Solution
When using a replication slot + publication instead of a yb-admin stream, the CDC stream options may not contain a
record_typekey, causingcdcStreamInfo.getOptions().get("record_type")to return null and the subsequent .equals() call to throw an NPE. Added a null check inYBClientUtils.isBeforeImageEnabled()— if record_type is missing, log a warning and return false (before image disabled).