From commits-return-34993-archive-asf-public=cust-asf.ponee.io@couchdb.apache.org Thu Oct 25 14:18:14 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id B2A36180675 for ; Thu, 25 Oct 2018 14:18:13 +0200 (CEST) Received: (qmail 77090 invoked by uid 500); 25 Oct 2018 12:18:12 -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 77078 invoked by uid 99); 25 Oct 2018 12:18:12 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2018 12:18:12 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 0DF3585165; Thu, 25 Oct 2018 12:18:11 +0000 (UTC) Date: Thu, 25 Oct 2018 12:18:12 +0000 To: "commits@couchdb.apache.org" Subject: [couchdb] 01/01: Fix get_minimum_purge_seq/1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: jiangphcn@apache.org In-Reply-To: <154046989169.7609.5823685102139308276@gitbox.apache.org> References: <154046989169.7609.5823685102139308276@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: couchdb X-Git-Refname: refs/heads/COUCHDB-3326-get_minimum_purge_seq X-Git-Reftype: branch X-Git-Rev: 91145016fe63513ab9e80100f6a4683f7aa911d7 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20181025121812.0DF3585165@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. jiangphcn pushed a commit to branch COUCHDB-3326-get_minimum_purge_seq in repository https://gitbox.apache.org/repos/asf/couchdb.git commit 91145016fe63513ab9e80100f6a4683f7aa911d7 Author: jiangph AuthorDate: Thu Oct 25 17:17:54 2018 +0800 Fix get_minimum_purge_seq/1 - should pass DbName instead of db record to validate client, and also display error when client doesn't exist, and mem3:dbname/1 to get DbName for get_design_docs/1 COUCHDB_3326 --- src/couch/src/couch_db.erl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl index 57e3951..f659002 100644 --- a/src/couch/src/couch_db.erl +++ b/src/couch/src/couch_db.erl @@ -425,20 +425,22 @@ get_minimum_purge_seq(#db{} = Db) -> case DocId of <> -> ClientSeq = couch_util:get_value(<<"purge_seq">>, Props), + DbName = couch_db:name(Db), + % If there's a broken doc we have to keep every + % purge info until the doc is fixed or removed. + Fmt = "Invalid purge doc '~s' on ~p with purge_seq '~w'", case ClientSeq of CS when is_integer(CS), CS >= PurgeSeq - PurgeInfosLimit -> {ok, SeqAcc}; CS when is_integer(CS) -> - case purge_client_exists(Db, DocId, Props) of - true -> {ok, erlang:min(CS, SeqAcc)}; - false -> {ok, SeqAcc} + case purge_client_exists(DbName, DocId, Props) of + true -> + {ok, erlang:min(CS, SeqAcc)}; + false -> + couch_log:error(Fmt, [DocId, DbName, ClientSeq]), + {ok, SeqAcc} end; _ -> - % If there's a broken doc we have to keep every - % purge info until the doc is fixed or removed. - Fmt = "Invalid purge doc '~s' on database ~p - with purge_seq '~w'", - DbName = couch_db:name(Db), couch_log:error(Fmt, [DocId, DbName, ClientSeq]), {ok, erlang:min(OldestPurgeSeq, SeqAcc)} end; @@ -491,7 +493,7 @@ purge_client_exists(DbName, DocId, Props) -> % it exists. Fmt2 = "Failed to check purge checkpoint using document '~p' in database ~p", - couch_log:error(Fmt2, [DbName, DocId]), + couch_log:error(Fmt2, [DocId, DbName]), true end. @@ -605,8 +607,8 @@ get_db_info(Db) -> ], {ok, InfoList}. -get_design_docs(#db{name = <<"shards/", _:18/binary, DbFullName/binary>>}) -> - DbName = ?l2b(filename:rootname(filename:basename(?b2l(DbFullName)))), +get_design_docs(#db{name = <<"shards/", _/binary>> = ShardDbName}) -> + DbName = mem3:dbname(ShardDbName), {_, Ref} = spawn_monitor(fun() -> exit(fabric:design_docs(DbName)) end), receive {'DOWN', Ref, _, _, Response} -> Response