This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 97dc9b0 feat: do not record server admin requests as cache misses
(#1755)
97dc9b0 is described below
commit 97dc9b05b2e75037739fef6834f0aefda04f8ac1
Author: Jan Lehnardt <[email protected]>
AuthorDate: Thu Nov 22 20:53:19 2018 +0100
feat: do not record server admin requests as cache misses (#1755)
Closes #1746
---
src/chttpd/src/chttpd_auth_cache.erl | 16 ++++++++++++----
src/couch/src/couch_compaction_daemon.erl | 2 +-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/chttpd/src/chttpd_auth_cache.erl
b/src/chttpd/src/chttpd_auth_cache.erl
index 4d85b16..638d8c7 100644
--- a/src/chttpd/src/chttpd_auth_cache.erl
+++ b/src/chttpd/src/chttpd_auth_cache.erl
@@ -73,8 +73,7 @@ get_from_cache(UserName) ->
couch_log:debug("cache hit for ~s", [UserName]),
Props;
_ ->
- couch_stats:increment_counter([couchdb, auth_cache_misses]),
- couch_log:debug("cache miss for ~s", [UserName]),
+ maybe_increment_auth_cache_miss(UserName),
case load_user_from_db(UserName) of
nil ->
nil;
@@ -84,11 +83,20 @@ get_from_cache(UserName) ->
end
catch
error:badarg ->
- couch_stats:increment_counter([couchdb, auth_cache_misses]),
- couch_log:debug("cache miss for ~s", [UserName]),
+ maybe_increment_auth_cache_miss(UserName),
load_user_from_db(UserName)
end.
+maybe_increment_auth_cache_miss(UserName) ->
+ Admins = config:get("admins"),
+ case lists:keymember(?b2l(UserName), 1, Admins) of
+ false ->
+ couch_stats:increment_counter([couchdb, auth_cache_misses]),
+ couch_log:debug("cache miss for ~s", [UserName]);
+ _True ->
+ ok
+ end.
+
%% gen_server callbacks
init([]) ->
diff --git a/src/couch/src/couch_compaction_daemon.erl
b/src/couch/src/couch_compaction_daemon.erl
index 72d5a17..1a535db 100644
--- a/src/couch/src/couch_compaction_daemon.erl
+++ b/src/couch/src/couch_compaction_daemon.erl
@@ -192,7 +192,7 @@ maybe_compact_db(Parent, DbName, Config) ->
couch_db:close(Db);
{error, Reason} ->
couch_db:close(Db),
- couch_log:error("Compaction daemon - an error ocurred
while"
+ couch_log:error("Compaction daemon - an error occurred
while"
" compacting the database `~s`: ~p", [DbName, Reason])
end,
case ViewsMonRef of