You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2018/09/06 16:20:22 UTC
[couchdb] 01/03: Fix couch_server:terminate/2
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch fix-couch-server-race-condition
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 7a469db180db6073b2163cf2cb4e8661c7bf39c9
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Sep 5 16:24:17 2018 -0500
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.
---
src/couch/src/couch_server.erl | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index ede8227..af728fa 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.