You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2017/03/01 16:38:58 UTC

[11/50] couch commit: updated refs/heads/2971-count-distinct to ee32cd5

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 <ii...@apache.org>
Authored: Thu Nov 3 09:05:00 2016 -0700
Committer: ILYA Khlopotov <ii...@apache.org>
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, <<RawBin:TotalBytes/binary>>} = 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)).