summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2018-11-22 16:40:56 +0100
committerJan Lehnardt <jan@apache.org>2018-11-22 18:58:49 +0100
commitb58abc21a1069a7a7e0dd6ee6c319ad94207a7a4 (patch)
tree7c6713e19ad5e25473c0a83d6da7bdfcc5bc31a6
parent4b3531b28a46383400103b1d3a81193d94c45ef4 (diff)
downloadcouchdb-fix/1764/admin-cache-miss.tar.gz
feat: do not record server admin requests as cache missesfix/1764/admin-cache-miss
Closes #1746
-rw-r--r--src/chttpd/src/chttpd_auth_cache.erl16
-rw-r--r--src/couch/src/couch_compaction_daemon.erl2
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 4d85b165b..638d8c748 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 72d5a17e2..1a535dba7 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