couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rand...@apache.org
Subject git commit: isolate db process crashes in couch_server
Date Sat, 26 Jan 2013 12:38:03 GMT
Updated Branches:
  refs/heads/1305-fix-isolate-db-crashes [created] 6f3feb09e


isolate db process crashes in couch_server

closes COUCHDB-1305


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

Branch: refs/heads/1305-fix-isolate-db-crashes
Commit: 6f3feb09e347dfe0c6812fd71e3f40d15d8d1ced
Parents: 67e75c2
Author: Randall Leeds <randall@apache.org>
Authored: Sat Jan 26 04:35:35 2013 -0800
Committer: Randall Leeds <randall@apache.org>
Committed: Sat Jan 26 04:35:35 2013 -0800

----------------------------------------------------------------------
 src/couchdb/couch_server.erl |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/6f3feb09/src/couchdb/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 6e25235..c9ffeab 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -449,6 +449,28 @@ handle_info({'EXIT', Pid, snappy_nif_not_loaded}, Server) ->
         Server
     end,
     {noreply, Server2};
+handle_info({'EXIT', Pid, Reason}=Error, Server) ->
+    case ets:lookup(couch_dbs_by_pid, Pid) of
+    [{Pid, Db}] ->
+        DbName = Db#db.name,
+        ?LOG_ERROR(
+           "Unexpected exit of database process ~p [~p], restarting: ~p",
+           [Pid, DbName, Reason]
+        ),
+        % If the Pid is known, the name should be as well.
+        % If not, that's an error we'll let crash out on this case statement.
+        case ets:lookup(couch_dbs_by_name, DbName) of
+        [{_, {opening, Pid, _Froms}}] ->
+            ok;
+        [{_, {opened, Pid, LruTime}}] ->
+            true = ets:delete(couch_dbs_by_lru, LruTime)
+        end,
+        true = ets:delete(couch_dbs_by_name, DbName),
+        true = ets:delete(couch_dbs_by_pid, DbName);
+    true ->
+        ?LOG_ERROR("Unexpected message, restarting couch_server: ~p", [Error])
+    end,
+    {noreply, Server};
 handle_info(Error, _Server) ->
     ?LOG_ERROR("Unexpected message, restarting couch_server: ~p", [Error]),
     exit(kill).


Mime
View raw message