Accept object-valued value and overheadFields in kafka entries - #2807
Accept object-valued value and overheadFields in kafka entries#2807delthas wants to merge 2 commits into
Conversation
createFromKafkaEntry coverage lived under tests/unit/replication/, while tests/unit/lib/models/ mirrors the source layout and already holds the sibling model specs. Pure relocation: only the two relative require paths change. Issue: BB-847
createFromKafkaEntry parsed the kafka message body and then parsed the nested value (and overheadFields) a second time, requiring producers to send them as JSON text. The D/R metadata stream is built by a MongoDB change-stream pipeline, which cannot serialise a document to a string — there is no $toJson and $convert rejects documents — so it can only emit these fields as objects. Decode them only when they are strings and pass objects through. This is a superset of the existing format: producers that stringify, S3C ingestion and the oplog reader, take the identical path. A field that is neither a string nor an object now yields the usual malformed-entry error naming the offending type. Previously JSON.parse coerced it, so an entry whose value was a number reached ObjectQueueEntry and passed checkSanity, since only bucket and key are checked. Issue: BB-847
Hello delthas,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
... and 2 files with indirect coverage changes
@@ Coverage Diff @@
## development/9.5 #2807 +/- ##
===================================================
- Coverage 75.76% 75.75% -0.02%
===================================================
Files 200 200
Lines 13922 13927 +5
===================================================
+ Hits 10548 10550 +2
- Misses 3364 3367 +3
Partials 10 10
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
francoisferrand
left a comment
There was a problem hiding this comment.
note: should land on 9.6 branch (waiting for "flaky" fix and 9.5.0 release) to create it
Done |
createFromKafkaEntryparses the kafka message body and then parses the nestedvalue— and, fordelentries,overheadFields— a second time, so producers have to send them as JSON text.The D/R metadata stream is built by a MongoDB change-stream pipeline (ZKOP-562), which cannot serialise a document to a string: there is no
$toJson, and$convertrejects documents. Manufacturing one for the consumer to parse straight back would mean either$function(per-document server-side JS on a production secondary, inside a change-stream pipeline) or a custom Kafka Connect SMT shipped in the kafka-connect image.The string requirement only exists because every producer so far builds entries in JavaScript —
ListRecordStreamdoesvalue: JSON.stringify(objectMd)on the oplog path, and S3C ingestion stringifies upstream. Nothing consumes the string form; it is parsed on receipt.So decode these fields only when they are strings, and pass objects through. That is a superset of the existing format: producers that stringify take the identical path, so ingestion is unaffected.
The first commit moves the
QueueEntryspec totests/unit/lib/models/, next to the model it tests.Issue: BB-847