couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r810358 - /couchdb/trunk/src/couchdb/couch_rep.erl
Date Wed, 02 Sep 2009 04:48:37 GMT
Author: kocolosk
Date: Wed Sep  2 04:48:36 2009
New Revision: 810358

URL: http://svn.apache.org/viewvc?rev=810358&view=rev
Log:
fix continuous replication occurring after identical normal one

Both forms of replication had the same child ID in the replication supervisor.
As a result, a continuous replication triggered after an otherwise-identical
normal replication would "forget" that it was continuous.

The tricky part about this patch is that it lets a normal and a continuous
replication with the same source and target execute simultaneously.  That's
inefficient, but other solutions are convoluted or give surprising results to
the client.

Modified:
    couchdb/trunk/src/couchdb/couch_rep.erl

Modified: couchdb/trunk/src/couchdb/couch_rep.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep.erl?rev=810358&r1=810357&r2=810358&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep.erl Wed Sep  2 04:48:36 2009
@@ -56,9 +56,9 @@
 
 %% function handling POST to _replicate
 replicate({Props}=PostBody, UserCtx) ->
-    RepId = make_replication_id(PostBody, UserCtx),
-    Replicator = {RepId,
-        {gen_server, start_link, [?MODULE, [RepId, PostBody, UserCtx], []]},
+    {BaseId, Extension} = make_replication_id(PostBody, UserCtx),
+    Replicator = {BaseId ++ Extension,
+        {gen_server, start_link, [?MODULE, [BaseId, PostBody, UserCtx], []]},
         transient,
         1,
         worker,
@@ -69,7 +69,7 @@
 
     case proplists:get_value(<<"continuous">>, Props, false) of
     true ->
-        {ok, {continuous, ?l2b(RepId)}};
+        {ok, {continuous, ?l2b(BaseId)}};
     false ->
         get_result(Server, PostBody, UserCtx)
     end.
@@ -361,7 +361,14 @@
     % Port = mochiweb_socket_server:get(couch_httpd, port),
     Src = get_rep_endpoint(UserCtx, proplists:get_value(<<"source">>, Props)),
     Tgt = get_rep_endpoint(UserCtx, proplists:get_value(<<"target">>, Props)),
   
-    couch_util:to_hex(erlang:md5(term_to_binary([HostName, Src, Tgt]))).
+    Base = couch_util:to_hex(erlang:md5(term_to_binary([HostName, Src, Tgt]))),
+    Extension = case proplists:get_value(<<"continuous">>, Props, false) of
+    true ->
+        "+continuous";
+    false ->
+        ""
+    end,
+    {Base, Extension}.
 
 maybe_add_trailing_slash(Url) ->
     re:replace(Url, "[^/]$", "&/", [{return, list}]).



Mime
View raw message