Skip to content

Commit

Permalink
Log problems opening database at ERROR level except for auto-created …
Browse files Browse the repository at this point in the history
…system dbs
  • Loading branch information
rnewson committed Nov 13, 2012
1 parent 2057b89 commit 4166764
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/couch_replicator/src/couch_replicator_manager.erl
Expand Up @@ -579,7 +579,7 @@ zone(Hr, Min) ->
ensure_rep_db_exists() ->
DbName = ?l2b(couch_config:get("replicator", "db", "_replicator")),
UserCtx = #user_ctx{roles = [<<"_admin">>, <<"_replicator">>]},
case couch_db:open_int(DbName, [sys_db, {user_ctx, UserCtx}]) of
case couch_db:open_int(DbName, [sys_db, {user_ctx, UserCtx}, nologifmissing]) of
{ok, Db} ->
Db;
_Error ->
Expand Down
2 changes: 1 addition & 1 deletion src/couchdb/couch_auth_cache.erl
Expand Up @@ -386,7 +386,7 @@ get_user_props_from_db(UserName) ->
).

ensure_users_db_exists(DbName, Options) ->
Options1 = [{user_ctx, #user_ctx{roles=[<<"_admin">>]}} | Options],
Options1 = [{user_ctx, #user_ctx{roles=[<<"_admin">>]}}, nologifmissing | Options],
case couch_db:open(DbName, Options1) of
{ok, Db} ->
ensure_auth_ddoc_exists(Db, <<"_design/_auth">>),
Expand Down
2 changes: 1 addition & 1 deletion src/couchdb/couch_db.erl
Expand Up @@ -51,7 +51,7 @@ open_db_file(Filepath, Options) ->
{error, enoent} ->
% couldn't find file. is there a compact version? This can happen if
% crashed during the file switch.
case couch_file:open(Filepath ++ ".compact") of
case couch_file:open(Filepath ++ ".compact", [nologifmissing]) of
{ok, Fd} ->
?LOG_INFO("Found ~s~s compaction file, using as primary storage.", [Filepath, ".compact"]),
ok = file:rename(Filepath ++ ".compact", Filepath),
Expand Down
8 changes: 6 additions & 2 deletions src/couchdb/couch_file.erl
Expand Up @@ -58,8 +58,12 @@ open(Filepath, Options) ->
{trap_exit, true} -> receive {'EXIT', Pid, _} -> ok end;
{trap_exit, false} -> ok
end,
?LOG_DEBUG("Could not open file ~s: ~s",
[Filepath, file:format_error(Reason)]),
case {lists:member(nologifmissing, Options), Reason} of
{true, enoent} -> ok;
_ ->
?LOG_ERROR("Could not open file ~s: ~s",
[Filepath, file:format_error(Reason)])
end,
Error
end;
Error ->
Expand Down

0 comments on commit 4166764

Please sign in to comment.