couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikewall...@apache.org
Subject [02/11] couch-replicator commit: updated refs/heads/2707-merge-couch_replicator-fixes-from-cloudant-fork to 80708a9
Date Fri, 05 Jun 2015 16:42:58 GMT
delay and splay replication starts

This is a cherry-pick of:

https://github.com/cloudant/couch_replicator/commit/d279150d959cfd46cbd77c5dd17f14d6dc3d0291


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/5b630ff8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/5b630ff8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/5b630ff8

Branch: refs/heads/2707-merge-couch_replicator-fixes-from-cloudant-fork
Commit: 5b630ff82b35b713941db094bef7a7beb6af66f1
Parents: 362b3fd
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Dec 3 12:14:10 2014 +0000
Committer: Mike Wallace <mikewallace@apache.org>
Committed: Fri Jun 5 17:20:15 2015 +0100

----------------------------------------------------------------------
 src/couch_replicator_manager.erl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/5b630ff8/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 17c766e..eefa0cd 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -454,7 +454,14 @@ maybe_start_replication(State, DbName, DocId, RepDoc) ->
         true = ets:insert(?DOC_TO_REP, {{DbName, DocId}, RepId}),
         couch_log:notice("Attempting to start replication `~s` (document `~s`).",
             [pp_rep_id(RepId), DocId]),
-        Pid = spawn_link(?MODULE, start_replication, [Rep, 0]),
+        StartDelaySecs = erlang:max(0,
+            config:get_integer("replicator", "start_delay", 10)),
+        StartSplaySecs = erlang:max(1,
+            config:get_integer("replicator", "start_splay", 50)),
+        DelaySecs = StartDelaySecs + random:uniform(StartSplaySecs),
+        couch_log:notice("Delaying replication `~s` start by ~p seconds.",
+            [pp_rep_id(RepId), DelaySecs]),
+        Pid = spawn_link(?MODULE, start_replication, [Rep, DelaySecs]),
         State#state{rep_start_pids = [Pid | State#state.rep_start_pids]};
     #rep_state{rep = #rep{doc_id = DocId}} ->
         State;


Mime
View raw message