fix(cdc): cast to GenericRecord in PostgresDebeziumAvroPayload toasted-value checks - #19564
Draft
yihua wants to merge 1 commit into
Draft
fix(cdc): cast to GenericRecord in PostgresDebeziumAvroPayload toasted-value checks#19564yihua wants to merge 1 commit into
yihua wants to merge 1 commit into
Conversation
…d-value checks BaseAvroPayload.getRecord returns a SerializableIndexedRecord when the payload record does not carry the exact Schema instance being merged with, so casting to GenericData.Record threw ClassCastException on any non-null BYTES column.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19564 +/- ##
============================================
- Coverage 76.84% 71.97% -4.87%
+ Complexity 32379 30327 -2052
============================================
Files 2522 2522
Lines 139106 139106
Branches 16713 16713
============================================
- Hits 106892 100123 -6769
- Misses 24621 31763 +7142
+ Partials 7593 7220 -373
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Collaborator
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.
Describe the issue this Pull Request addresses
closes #19563
PostgresDebeziumAvroPayloadcasts to the concrete classGenericData.RecordinmergeToastedValuesIfPresentandcontainsBytesToastedValues. Since #13987 ("perf: Lazy deserialization of Avro indexed record"),BaseAvroPayload.getRecordreturns aSerializableIndexedRecordwhenever the payload's record does not already carry the exactSchemainstance being merged with, which is the ordinary case in production and after any Kryo round trip.SerializableIndexedRecordimplementsGenericRecordbut does not extendGenericData.Record, so any TOAST check on a non-nullBYTEScolumn throwsClassCastException. The siblingcontainsStringToastedValueswas already converted to the interface, which is why onlyBYTEScolumns are affected.Summary and Changelog
Debezium Postgres ingestion of tables with a
BYTEScolumn no longer fails when the incoming event wins the LSN comparison.PostgresDebeziumAvroPayload: cast to theGenericRecordinterface instead of theGenericData.Recordimplementation, inmergeToastedValuesIfPresent(the record already in storage) and in both reads insidecontainsBytesToastedValues.TestPostgresDebeziumAvroPayload#testMergeWithToastedValues: turned into a parameterized test over two independent dimensions, whether the incoming record is lazily deserialized (built on an equal but distinctSchemainstance, which forces the round trip) and whether the record already in storage is aSerializableIndexedRecord. An added assertion pins that the lazy path is actually taken, so the parameterization cannot quietly degrade into four copies of the original case. Reverting the payload change fails 3 of the 4 cases with the reportedClassCastException; the pre-existing case is the one that passed before.Impact
None beyond fixing the crash. The interface cast accepts everything the implementation cast accepted.
Risk Level
low
Covered by the parameterized regression test above, verified to fail without the payload change.
Documentation Update
none
Contributor's checklist