You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by mi...@apache.org on 2015/06/02 19:29:11 UTC
[04/13] couch-replicator commit: updated
refs/heads/2707-merge-couch_replicator-fixes-from-cloudant-fork to 367562b
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/ea39d118
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/ea39d118
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/ea39d118
Branch: refs/heads/2707-merge-couch_replicator-fixes-from-cloudant-fork
Commit: ea39d118a08781f003b8756dee3324d65038f7a9
Parents: 74da56e
Author: Robert Newson <rn...@apache.org>
Authored: Wed Dec 3 12:14:10 2014 +0000
Committer: Mike Wallace <mi...@apache.org>
Committed: Tue Jun 2 17:46:25 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/ea39d118/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 17c766e..0cb0ce4 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, list_to_integer(
+ config:get("replicator", "start_delay", "10"))),
+ StartSplaySecs = erlang:max(1, list_to_integer(
+ config:get("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;