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 84C37200C39 for ; Wed, 1 Mar 2017 17:38:52 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 83BBB160B7F; Wed, 1 Mar 2017 16:38:52 +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 2A585160B83 for ; Wed, 1 Mar 2017 17:38:51 +0100 (CET) Received: (qmail 81126 invoked by uid 500); 1 Mar 2017 16:38:49 -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 80127 invoked by uid 99); 1 Mar 2017 16:38:48 -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:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 44F19F1755; Wed, 1 Mar 2017 16:38:48 +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:58 -0000 Message-Id: <1a3ffb879ab2495cbe12ee65d105ebd6@git.apache.org> In-Reply-To: <291c3c1659274535834e6cfd18c686fd@git.apache.org> References: <291c3c1659274535834e6cfd18c686fd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/50] couch commit: updated refs/heads/2971-count-distinct to ee32cd5 archived-at: Wed, 01 Mar 2017 16:38:52 -0000 Include file_path on errors from couch_file Add PathFile as part of a reason for following errors: - read_beyond_eof - exceed_pread_limit exceptions Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/9c98070c Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/9c98070c Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/9c98070c Branch: refs/heads/2971-count-distinct Commit: 9c98070cc91bd4064ab158f60b7356fb21459acf Parents: 189af37 Author: ILYA Khlopotov Authored: Thu Nov 3 09:05:00 2016 -0700 Committer: ILYA Khlopotov Committed: Thu Nov 3 11:41:44 2016 -0700 ---------------------------------------------------------------------- src/couch_file.erl | 14 ++++++++------ test/couch_file_tests.erl | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/9c98070c/src/couch_file.erl ---------------------------------------------------------------------- diff --git a/src/couch_file.erl b/src/couch_file.erl index e7d9413..19e5998 100644 --- a/src/couch_file.erl +++ b/src/couch_file.erl @@ -428,10 +428,10 @@ handle_call({pread_iolist, Pos}, _From, File) -> % up to 8Kbs of read ahead read_raw_iolist_int(File, Pos, ?READ_AHEAD - (Pos rem ?SIZE_BLOCK)) catch - throw:read_beyond_eof -> - throw(read_beyond_eof); - throw:{exceed_pread_limit, Limit} -> - throw({exceed_pread_limit, Limit}); + throw:{read_beyond_eof, _} = Reason -> + throw(Reason); + throw:{exceed_pread_limit, _, _} = Reason -> + throw(Reason); _:_ -> read_raw_iolist_int(File, Pos, 4) end, @@ -625,10 +625,12 @@ read_raw_iolist_int(#file{fd = Fd, pread_limit = Limit} = F, Pos, Len) -> case Pos + TotalBytes of Size when Size > F#file.eof + ?READ_AHEAD -> couch_stats:increment_counter([pread, exceed_eof]), - throw(read_beyond_eof); + {_Fd, Filepath} = get(couch_file_fd), + throw({read_beyond_eof, Filepath}); Size when Size > Limit -> couch_stats:increment_counter([pread, exceed_limit]), - throw({exceed_pread_limit, Limit}); + {_Fd, Filepath} = get(couch_file_fd), + throw({exceed_pread_limit, Filepath, Limit}); Size -> {ok, <>} = file:pread(Fd, Pos, TotalBytes), {remove_block_prefixes(BlockOffset, RawBin), Size} http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/9c98070c/test/couch_file_tests.erl ---------------------------------------------------------------------- diff --git a/test/couch_file_tests.erl b/test/couch_file_tests.erl index 497999e..c16be16 100644 --- a/test/couch_file_tests.erl +++ b/test/couch_file_tests.erl @@ -139,7 +139,8 @@ should_not_read_beyond_eof(Fd) -> ok = file:pwrite(Io, Pos, <<0:1/integer, DoubleBin:31/integer>>), file:close(Io), unlink(Fd), - ExpectedError = {badmatch, {'EXIT', {bad_return_value, read_beyond_eof}}}, + ExpectedError = {badmatch, {'EXIT', {bad_return_value, + {read_beyond_eof, Filepath}}}}, ?_assertError(ExpectedError, couch_file:pread_binary(Fd, Pos)). should_truncate(Fd) -> @@ -175,11 +176,12 @@ pread_limit_test_() -> }. should_not_read_more_than_pread_limit(Fd) -> + {_, Filepath} = couch_file:process_info(Fd), BigBin = list_to_binary(lists:duplicate(100000, 0)), {ok, Pos, _Size} = couch_file:append_binary(Fd, BigBin), unlink(Fd), ExpectedError = {badmatch, {'EXIT', {bad_return_value, - {exceed_pread_limit, 50000}}}}, + {exceed_pread_limit, Filepath, 50000}}}}, ?_assertError(ExpectedError, couch_file:pread_binary(Fd, Pos)).