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 153B311AC4 for ; Fri, 1 Aug 2014 14:29:43 +0000 (UTC) Received: (qmail 4758 invoked by uid 500); 1 Aug 2014 14:29:42 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 4594 invoked by uid 500); 1 Aug 2014 14:29: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 4130 invoked by uid 99); 1 Aug 2014 14:29:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Aug 2014 14:29:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A5D5C9BD319; Fri, 1 Aug 2014 14:29:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Fri, 01 Aug 2014 14:29:53 -0000 Message-Id: In-Reply-To: <3ee12231c6834b8da69413f9261f3e3f@git.apache.org> References: <3ee12231c6834b8da69413f9261f3e3f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/23] fabric commit: updated refs/heads/windsor-merge to 4ec3f11 Only attempt replacement when we have replacements We weren't checking if we were even provided replacements before using them. This just adds a guard so we don't end up with a badmatch error on the `lists:keytake/3`. BugzId: 26124 Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/813e3437 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/813e3437 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/813e3437 Branch: refs/heads/windsor-merge Commit: 813e34377b6bc59c7ebdbbeb9e5aed3fe27fd45f Parents: 6408f7f Author: Paul J. Davis Authored: Thu Dec 12 12:51:46 2013 -0600 Committer: Robert Newson Committed: Fri Aug 1 15:13:58 2014 +0100 ---------------------------------------------------------------------- src/fabric_util.erl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/813e3437/src/fabric_util.erl ---------------------------------------------------------------------- diff --git a/src/fabric_util.erl b/src/fabric_util.erl index 642d7d6..5f59725 100644 --- a/src/fabric_util.erl +++ b/src/fabric_util.erl @@ -86,13 +86,14 @@ handle_stream_start({rexi_DOWN, _, {_, NodeRef}, _}, _, St) -> end; handle_stream_start({rexi_EXIT, Reason}, Worker, St) -> Workers = fabric_dict:erase(Worker, St#stream_acc.workers), + Replacements = St#stream_acc.replacements, case {fabric_view:is_progress_possible(Workers), Reason} of {true, _} -> {ok, St#stream_acc{workers=Workers}}; - {false, {maintenance_mode, _Node}} -> + {false, {maintenance_mode, _Node}} when Replacements /= undefined -> % Check if we have replacements for this range % and start the new workers if so. - case lists:keytake(Worker#shard.range, 1, St#stream_acc.replacements) of + case lists:keytake(Worker#shard.range, 1, Replacements) of {value, {_Range, WorkerReplacements}, NewReplacements} -> FinalWorkers = lists:foldl(fun(Repl, NewWorkers) -> NewWorker = (St#stream_acc.start_fun)(Repl),