You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/06 13:55:06 UTC

[29/48] couch commit: updated refs/heads/windsor-merge-300 to 2c2f53e

Silence log spam when couch_file closes

If a couch_file closes the couch_db_updater will go along with it with a
great deal of fanfare when the actual interesting error message is from
couch_file. Rather than blow up trying to close a dead process we just
exit more quietly (albeit still with a log message).

The observed cause of this is when a database is opened before
couch_stats_collector boots and starts tracking processes. A minute
after the node boots we get a number of couch_db_updaters that die
because their fd closed due to a lack of monitor from
couch_stats_collector.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/ef1af372
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/ef1af372
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/ef1af372

Branch: refs/heads/windsor-merge-300
Commit: ef1af372268318dca1b092e9cb20ddc6152580ab
Parents: bc4ec1b
Author: Paul J. Davis <pa...@gmail.com>
Authored: Fri Jun 14 19:46:14 2013 -0500
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Aug 5 16:40:37 2014 +0100

----------------------------------------------------------------------
 src/couch_db_updater.erl | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/ef1af372/src/couch_db_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl
index 22384dc..5cdb876 100644
--- a/src/couch_db_updater.erl
+++ b/src/couch_db_updater.erl
@@ -66,13 +66,10 @@ init({DbName, Filepath, Fd, Options}) ->
 
 
 terminate(_Reason, Db) ->
-    % If the reason we died is becuase our fd disappeared
+    % If the reason we died is because our fd disappeared
     % then we don't need to try closing it again.
-    case Db#db.fd of
-        Pid when is_pid(Pid) ->
-            ok = couch_file:close(Db#db.fd);
-        _ ->
-            ok
+    if Db#db.fd_monitor == closed -> ok; true ->
+        ok = couch_file:close(Db#db.fd)
     end,
     couch_util:shutdown_sync(Db#db.compactor_pid),
     couch_util:shutdown_sync(Db#db.fd),
@@ -317,7 +314,7 @@ handle_info({'EXIT', _Pid, Reason}, Db) ->
     {stop, Reason, Db};
 handle_info({'DOWN', Ref, _, _, Reason}, #db{fd_monitor=Ref, name=Name} = Db) ->
     ?LOG_ERROR("DB ~s shutting down - Fd ~p", [Name, Reason]),
-    {stop, normal, Db#db{fd=undefined, fd_monitor=undefined}}.
+    {stop, normal, Db#db{fd=undefined, fd_monitor=closed}}.
 
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.