summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2017-06-05 18:05:06 -0400
committerNick Vatamaniuc <vatamane@apache.org>2017-06-05 18:21:11 -0400
commit7cd630f82fa0bbbcb8892d5fa72f7bde88b1b071 (patch)
treeb23ec35374b98cd3f4fbe5f816506964273911fa
parent3f99f01b7c03535e2228e1c609bc6eaab1818c31 (diff)
downloadcouchdb-COUCHDB-3287-pluggable-storage-engines-mixed-cluster-attachments.tar.gz
Handle attachments in a mixed cluster environment.COUCHDB-3287-pluggable-storage-engines-mixed-cluster-attachments
Previously attachment uploading would fail if non-PSE nodes would push attachment to PSE nodes. This commit handles dynamic translation of previous attachment streamer format to the new PSE-version.
-rw-r--r--src/couch/src/couch_att.erl13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/couch/src/couch_att.erl b/src/couch/src/couch_att.erl
index bd53086cd..ae08c2fdc 100644
--- a/src/couch/src/couch_att.erl
+++ b/src/couch/src/couch_att.erl
@@ -490,6 +490,19 @@ flush(Db, Att) ->
flush_data(Db, fetch(data, Att), Att).
+flush_data(Db, {Fd, StreamPointer}, Att) when is_pid(Fd) ->
+ % Temporary clause to handle previous non-PSE versions in a mixed cluster.
+ % Only applicable to for (default) couch_bt_engine. Remove in next release.
+ case couch_db_engine:get_engine(Db) of
+ couch_bt_engine ->
+ StreamEngine = {couch_bt_engine_stream, {Fd, StreamPointer}},
+ flush_data(Db, {stream, StreamEngine}, Att);
+ OtherEngine ->
+ Msg = "Mixed (PSE vs non-PSE) cluster attachment handling only"
+ "supported for default couch_bt_engine not ~p",
+ couch_log:error(Msg, OtherEngine),
+ erlang:error({unsupported_mixed_cluster_configuration, OtherEngine})
+ end;
flush_data(Db, Data, Att) when is_binary(Data) ->
couch_db:with_stream(Db, Att, fun(OutputStream) ->
couch_stream:write(OutputStream, Data)