summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2018-09-05 16:24:17 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2018-09-06 14:12:34 -0500
commit2195eb352952e66494ec520e920733808e028c0d (patch)
tree2e36521fa94bdfa6df860a950968157712a22ec4
parent485e9ca62135808b4f82d18733efd051cf1563d4 (diff)
downloadcouchdb-2195eb352952e66494ec520e920733808e028c0d.tar.gz
Fix couch_server:terminate/2
If couch_server terminates while there is an active open_async process it will throw a function_clause exception because `couch_db:get_pid/1` will fail due to the `#entry.db` member being undefined. Simple fix is to just filter those out.
-rw-r--r--src/couch/src/couch_server.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index ede8227c8..af728fa01 100644
--- a/src/couch/src/couch_server.erl
+++ b/src/couch/src/couch_server.erl
@@ -244,7 +244,11 @@ terminate(Reason, Srv) ->
[Reason,
Srv#server{lru = redacted}]),
ets:foldl(fun(#entry{db = Db}, _) ->
- couch_util:shutdown_sync(couch_db:get_pid(Db))
+ % Filter out any entry records for open_async
+ % processes that haven't finished.
+ if Db == undefined -> ok; true ->
+ couch_util:shutdown_sync(couch_db:get_pid(Db))
+ end
end, nil, couch_dbs),
ok.