diff options
author | Jan Lehnardt <jan@apache.org> | 2018-11-22 20:53:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-22 20:53:19 +0100 |
commit | 97dc9b05b2e75037739fef6834f0aefda04f8ac1 (patch) | |
tree | 7c6713e19ad5e25473c0a83d6da7bdfcc5bc31a6 | |
parent | 4b3531b28a46383400103b1d3a81193d94c45ef4 (diff) | |
download | couchdb-97dc9b05b2e75037739fef6834f0aefda04f8ac1.tar.gz |
feat: do not record server admin requests as cache misses (#1755)
Closes #1746
-rw-r--r-- | src/chttpd/src/chttpd_auth_cache.erl | 16 | ||||
-rw-r--r-- | 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 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 |