Add stats counters for exceed_eof and exceed_limit
diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
index c695ae4..8b83e0c 100644
--- a/priv/stats_descriptions.cfg
+++ b/priv/stats_descriptions.cfg
@@ -218,3 +218,11 @@
{type, histogram},
{desc, <<"duration of validate_doc_update function calls">>}
]}.
+{[pread, exceed_eof], [
+ {type, counter},
+ {desc, <<"number of the attempts to read beyond end of db file">>}
+]}.
+{[pread, exceed_limit], [
+ {type, counter},
+ {desc, <<"number of the attempts to read beyond set limit">>}
+]}.
diff --git a/src/couch_file.erl b/src/couch_file.erl
index 03c2628..d2b3960 100644
--- a/src/couch_file.erl
+++ b/src/couch_file.erl
@@ -570,8 +570,10 @@
TotalBytes = calculate_total_read_len(BlockOffset, Len),
case Pos + TotalBytes of
Size when Size > F#file.eof + ?READ_AHEAD ->
+ couch_stats:increment_counter([pread, exceed_eof]),
throw(read_beyond_eof);
Size when Size > Limit ->
+ couch_stats:increment_counter([pread, exceed_limit]),
throw({exceed_pread_limit, Limit});
Size ->
{ok, <<RawBin:TotalBytes/binary>>} = file:pread(Fd, Pos, TotalBytes),