Pull replication: attachment bodies (phase 2)#214
Open
benoitc wants to merge 2 commits into
Open
Conversation
Fetch each missing revision via the multipart open_doc path and reassemble the
document together with its attachment bodies, handed to the target as
{Doc, #{AttName => Bin}}. Bytes are kept as delivered (encoding recorded in the
doc's _attachments). The target behaviour contract is unchanged from phase 1.
- couchbeam_replicator: fetch_rev uses {revs,true} + attachments via stream_doc
- couchbeam: fix open_doc/3 and stream_doc/1 specs to include the multipart
returns ({ok,{multipart,_}} and {doc, Doc, doc_stream()}) so dialyzer passes
- e2e: pull_replication_attachments asserts the body is replicated verbatim and
the _attachments stub is preserved
- guide + CHANGELOG updated
- pull_replication_conflicts: a doc with two conflicting leaf revisions (built via bulk_docs new_edits=false) replicates all leaves with history - pull_replication_continuous: continuous mode imports a doc added while the replicator is running, then stops cleanly
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.
Phase 2 of 2 (builds on #213). Adds attachment-body replication to the pull replicator. The target behaviour contract is unchanged from phase 1.
What changed
couchbeam_replicator:fetch_revnow requests each revision with{revs,true}andattachments=true, reassembling the document and its attachment bodies via the multipartcouchbeam:stream_doc/1path. Each target entry is{Doc, #{AttName => Bin}}; a revision with no attachments (or a deletion) still comes back as plain JSON with#{}. Bytes are stored as delivered (the doc's_attachmentsrecords content type and any encoding, e.g. gzip for compressible types).couchbeam: fixed theopen_doc/3andstream_doc/1-specs, which omitted the real multipart returns ({ok, {multipart, _}}and{doc, Doc, doc_stream()}). dialyzer caught the mismatch via the replicator; the specs now match runtime behaviour.Tests
pull_replication_attachments(in thepull_replication_opsgroup) puts an attachment on a source doc, replicates into the ets target, and asserts the body is replicated verbatim and the_attachmentsstub is preserved.Verified:
rebar3 eunit(32),xref,dialyzerclean;make e2egreen across all groups (replication group now 3 tests) on CouchDB 3.5.x.