couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikewall...@apache.org
Subject [01/13] couch-replicator commit: updated refs/heads/master to 80708a9
Date Fri, 05 Jun 2015 16:47:41 GMT
Repository: couchdb-couch-replicator
Updated Branches:
  refs/heads/master bbab85b9f -> 80708a99e


Use randomized, truncated exponential backoff in event of conflict

BugzID: 42053

This is a cherry-pick of:

https://github.com/cloudant/couch_replicator/commit/6e8fbb6a3f2622c14ae605c18ec54cbad7d389f3

Conflicts:
	src/couch_replicator_manager.erl


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

Branch: refs/heads/master
Commit: dcb38869bdb1ed44bb90ed45bc993a6452be1cb6
Parents: bbab85b
Author: Robert Newson <rnewson@apache.org>
Authored: Mon Dec 1 11:11:00 2014 +0000
Committer: Mike Wallace <mikewallace@apache.org>
Committed: Tue Jun 2 17:43:00 2015 +0100

----------------------------------------------------------------------
 src/couch_replicator_manager.erl | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/dcb38869/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index caae55f..0fcb0c4 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -596,11 +596,14 @@ clean_up_replications(DbName) ->
     ets:delete(?DB_TO_SEQ,DbName).
 
 
-update_rep_doc(RepDbName, RepDocId, KVs) when is_binary(RepDocId) ->
+update_rep_doc(RepDbName, RepDocId, KVs) ->
+    update_rep_doc(RepDbName, RepDocId, KVs, 1).
+
+update_rep_doc(RepDbName, RepDocId, KVs, Wait) when is_binary(RepDocId) ->
     try
         case open_rep_doc(RepDbName, RepDocId) of
             {ok, LastRepDoc} ->
-                update_rep_doc(RepDbName, LastRepDoc, KVs);
+                update_rep_doc(RepDbName, LastRepDoc, KVs, Wait * 2);
             _ ->
                 ok
         end
@@ -608,10 +611,10 @@ update_rep_doc(RepDbName, RepDocId, KVs) when is_binary(RepDocId) ->
         throw:conflict ->
             Msg = "Conflict when updating replication document `~s`. Retrying.",
             couch_log:error(Msg, [RepDocId]),
-            ok = timer:sleep(5),
-            update_rep_doc(RepDbName, RepDocId, KVs)
+            ok = timer:sleep(random:uniform(erlang:min(128, Wait)) * 100),
+            update_rep_doc(RepDbName, RepDocId, KVs, Wait * 2)
     end;
-update_rep_doc(RepDbName, #doc{body = {RepDocBody}} = RepDoc, KVs) ->
+update_rep_doc(RepDbName, #doc{body = {RepDocBody}} = RepDoc, KVs, _Try) ->
     NewRepDocBody = lists:foldl(
         fun({K, undefined}, Body) ->
                 lists:keydelete(K, 1, Body);


Mime
View raw message