summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2018-07-17 14:53:26 -0400
committerNick Vatamaniuc <nickva@users.noreply.github.com>2018-07-17 16:46:12 -0400
commit56782453f342fb5e4137e8c9afc79b1992a8b21a (patch)
tree541229c7a56669cf392c3f2a08c63d0875053a9d
parente2f7561ae0f3cb8e6791342a2e7e14e2ee39f3b8 (diff)
downloadcouchdb-56782453f342fb5e4137e8c9afc79b1992a8b21a.tar.gz
Switch fabric attachment receiver to use messages
Function closures are fragile and attachment uploads would break if fabric_doc_attachments is different on any of the nodes in a cluster, like it might happen during a roling cluster upgrade. Previously fe53e437ca5ec9d23aa1b55d7934daced157a9e3 introduced two versions of the module one which handles function closure, other which handled message but only in this commit messages are starting to be sent. To avoid breakages in attachemnt uploads during the period of a rolling cluster upgrade, make sure to upgrade to that commit first then upgrade to this change. Issue #1394
-rw-r--r--src/fabric/src/fabric.erl9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/fabric/src/fabric.erl b/src/fabric/src/fabric.erl
index 4a0727131..f5c793736 100644
--- a/src/fabric/src/fabric.erl
+++ b/src/fabric/src/fabric.erl
@@ -271,13 +271,14 @@ purge_docs(_DbName, _IdsRevs) ->
not_implemented.
%% @doc spawns a process to upload attachment data and
-%% returns a function that shards can use to communicate
-%% with the spawned middleman process
+%% returns a fabric attachment receiver context tuple
+%% with the spawned middleman process, an empty binary,
+%% or exits with an error tuple {Error, Arg}
-spec att_receiver(#httpd{}, Length :: undefined | chunked | pos_integer() |
{unknown_transfer_encoding, any()}) ->
- function() | binary().
+ {fabric_attachment_receiver, pid(), chunked | pos_integer()} | binary().
att_receiver(Req, Length) ->
- fabric_doc_attachments:receiver(Req, Length).
+ fabric_doc_atts:receiver(Req, Length).
%% @equiv all_docs(DbName, [], Callback, Acc0, QueryArgs)
all_docs(DbName, Callback, Acc, QueryArgs) ->