couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject git commit: Fix bug in replicator request piplining
Date Tue, 31 Jan 2012 19:22:39 GMT
Updated Branches:
  refs/heads/1.1.x b4cf77b9d -> 963d7f728


Fix bug in replicator request piplining

A replication with both an HTTP source and target on the same host and
port could end up in a dead lock due to ibrowse replication pipelining
when attachments are present on the source. The ibrowse http worker
would end up forming a multipart/mime body using anonymous reader
functions for attachment stubs. When the attachment stub functions are
executed it is possible that they end up assigned to the same ibrowse
worker.

This is a bit of a long path but then end result is equivalent to
calling gen_server:call(self(), Args, infinity) from a gen_server
callback.

A quick work around for users is to set up a DNA alias (possibly in
/etc/hosts) or to use a combination of hostname and ip address so that
ibrowse assigns the requests to different pools.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/963d7f72
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/963d7f72
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/963d7f72

Branch: refs/heads/1.1.x
Commit: 963d7f728039cb7a6d5558239116091731c32781
Parents: b4cf77b
Author: Paul Joseph Davis <davisp@apache.org>
Authored: Tue Jan 31 14:11:10 2012 -0500
Committer: Paul Joseph Davis <davisp@apache.org>
Committed: Tue Jan 31 14:19:50 2012 -0500

----------------------------------------------------------------------
 CHANGES                          |    1 +
 NEWS                             |    1 +
 src/couchdb/couch_rep_writer.erl |   19 ++++++++++++-------
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/963d7f72/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 92a007e..dbd0373 100644
--- a/CHANGES
+++ b/CHANGES
@@ -14,6 +14,7 @@ HTTP Interface:
 Replicator:
 
 * Fix pull replication of documents with many revisions.
+* Fix replication from an HTTP source to an HTTP target.
 
 Version 1.1.1
 -------------

http://git-wip-us.apache.org/repos/asf/couchdb/blob/963d7f72/NEWS
----------------------------------------------------------------------
diff --git a/NEWS b/NEWS
index 822129a..d231234 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ This version has not been released yet.
 * ETag of attachment changes only when the attachment changes, not
  the document.
 * Fix pull replication of documents with many revisions.
+* Fix replication with an HTTP source and target
 
 Version 1.1.1
 -------------

http://git-wip-us.apache.org/repos/asf/couchdb/blob/963d7f72/src/couchdb/couch_rep_writer.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_rep_writer.erl b/src/couchdb/couch_rep_writer.erl
index 4032392..cea4408 100644
--- a/src/couchdb/couch_rep_writer.erl
+++ b/src/couchdb/couch_rep_writer.erl
@@ -126,13 +126,18 @@ write_multi_part_doc(#http_db{headers=Headers} = Db, #doc{atts=Atts}
= Doc) ->
             {"Content-Length", Len} | Headers
         ]
     },
-    Result = case couch_rep_httpc:request(Request) of
-    {[{<<"error">>, Error}, {<<"reason">>, Reason}]} ->
-        {Pos, [RevId | _]} = Doc#doc.revs,
-        ErrId = couch_util:to_existing_atom(Error),
-        [{Doc#doc.id, couch_doc:rev_to_str({Pos, RevId})}, {ErrId, Reason}];
-    _ ->
-        []
+    Conn = couch_rep_httpc:spawn_link_worker_process(Request),
+    Result = try
+        case couch_rep_httpc:request(Request#http_db{conn=Conn}) of
+        {[{<<"error">>, Error}, {<<"reason">>, Reason}]} ->
+            {Pos, [RevId | _]} = Doc#doc.revs,
+            ErrId = couch_util:to_existing_atom(Error),
+            [{Doc#doc.id, couch_doc:rev_to_str({Pos, RevId})}, {ErrId, Reason}];
+        _ ->
+            []
+        end
+    after
+        ibrowse:stop_worker_process(Conn)
     end,
     StreamerPid ! stop,
     Result.


Mime
View raw message