Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CD01D200C2A for ; Wed, 1 Mar 2017 17:38:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CBC0E160B56; Wed, 1 Mar 2017 16:38:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B42EA160B87 for ; Wed, 1 Mar 2017 17:38:04 +0100 (CET) Received: (qmail 75810 invoked by uid 500); 1 Mar 2017 16:38:01 -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 75579 invoked by uid 99); 1 Mar 2017 16:38:01 -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; Wed, 01 Mar 2017 16:38:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E14B5DFE60; Wed, 1 Mar 2017 16:38:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kocolosk@apache.org To: commits@couchdb.apache.org Date: Wed, 01 Mar 2017 16:38:45 -0000 Message-Id: <0058df12934548af980137f764508811@git.apache.org> In-Reply-To: <925479a7649544f8927df3a0988e9cee@git.apache.org> References: <925479a7649544f8927df3a0988e9cee@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [47/50] fabric commit: updated refs/heads/2971-count-distinct to 5d18415 archived-at: Wed, 01 Mar 2017 16:38:05 -0000 Use RealReplyCount to distinguish worker replies and invalid docs We use {ok, []} in couch_db:open_doc_revs_int/3 as a return value when the document does not exist and open_revs=all. This leads to an incorrect all_workers_died error. We use ReplyCount and RealReplyCount to distinguish between when no workers were actually used in a reply versus when the document does not exist COUCHDB-3113 Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/70535eeb Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/70535eeb Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/70535eeb Branch: refs/heads/2971-count-distinct Commit: 70535eeb9b9c226129bdc96cbca8492fbc867cf6 Parents: cf220b2 Author: Tony Sun Authored: Fri Feb 10 11:23:07 2017 -0800 Committer: Tony Sun Committed: Fri Feb 10 11:23:07 2017 -0800 ---------------------------------------------------------------------- src/fabric_doc_open_revs.erl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/70535eeb/src/fabric_doc_open_revs.erl ---------------------------------------------------------------------- diff --git a/src/fabric_doc_open_revs.erl b/src/fabric_doc_open_revs.erl index 6c8912b..096722f 100644 --- a/src/fabric_doc_open_revs.erl +++ b/src/fabric_doc_open_revs.erl @@ -47,7 +47,7 @@ go(DbName, Id, Revs, Options) -> }, RexiMon = fabric_util:create_monitors(Workers), try fabric_util:recv(Workers, #shard.ref, fun handle_message/3, State) of - {ok, []} -> + {ok, all_workers_died} -> {error, all_workers_died}; {ok, Replies} -> {ok, Replies}; @@ -92,8 +92,9 @@ handle_message({ok, RawReplies}, Worker, State) -> IsTree = Revs == all orelse Latest, % Do not count error replies when checking quorum - QuorumReplies = ReplyCount + 1 - ReplyErrorCount >= R, + RealReplyCount = ReplyCount + 1 - ReplyErrorCount, + QuorumReplies = RealReplyCount >= R, {NewReplies, QuorumMet, Repair} = case IsTree of true -> {NewReplies0, AllInternal, Repair0} = @@ -119,7 +120,7 @@ handle_message({ok, RawReplies}, Worker, State) -> ReplyCount + 1, InRepair orelse Repair ), - {stop, format_reply(IsTree, NewReplies)}; + {stop, format_reply(IsTree, NewReplies, RealReplyCount)}; false -> {ok, State#state{ replies = NewReplies, @@ -219,10 +220,13 @@ read_repair(Db, Docs) -> end. -format_reply(true, Replies) -> +format_reply(_, _, RealReplyCount) when RealReplyCount =< 0 -> + all_workers_died; + +format_reply(true, Replies, _) -> tree_format_replies(Replies); -format_reply(false, Replies) -> +format_reply(false, Replies, _) -> Filtered = filter_reply(Replies), dict_format_replies(Filtered). @@ -500,7 +504,7 @@ check_empty_list_when_no_workers_reply() -> Msg1 = {rexi_EXIT, reason}, Msg2 = {rexi_EXIT, reason}, Msg3 = {rexi_DOWN, nodedown, {nil, node()}, nil}, - Expect = {stop, []}, + Expect = {stop, all_workers_died}, {ok, S1} = handle_message(Msg1, w1, S0), {ok, S2} = handle_message(Msg2, w2, S1),