This is an automated email from the ASF dual-hosted git repository. jan pushed a commit to branch fix/1764/admin-cache-miss in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 3375fcb5de92c0b5e0d75812ddc6129f15ddcf5a Author: Jan Lehnardt <[email protected]> AuthorDate: Thu Nov 22 16:40:56 2018 +0100 feat: do not record server admin requests as cache misses Closes #1764 --- 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..a0a540d 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 proplists:get_value(?b2l(UserName), Admins) of + undefined -> + couch_stats:increment_counter([couchdb, auth_cache_misses]), + couch_log:debug("cache miss for ~s", [UserName]); + _Else -> + 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
