Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B02C418863 for ; Fri, 5 Jun 2015 16:47:42 +0000 (UTC) Received: (qmail 37973 invoked by uid 500); 5 Jun 2015 16:47:42 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 37771 invoked by uid 500); 5 Jun 2015 16:47:42 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 37475 invoked by uid 99); 5 Jun 2015 16:47:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jun 2015 16:47:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 06515E10A7; Fri, 5 Jun 2015 16:47:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mikewallace@apache.org To: commits@couchdb.apache.org Date: Fri, 05 Jun 2015 16:47:44 -0000 Message-Id: <1fd95781f1ff40d7b93439f148dd1a2a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/13] couch-replicator commit: updated refs/heads/master to 80708a9 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/master Commit: 5b630ff82b35b713941db094bef7a7beb6af66f1 Parents: 362b3fd Author: Robert Newson Authored: Wed Dec 3 12:14:10 2014 +0000 Committer: Mike Wallace 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;