From f5292d8ba971391a7b1796382770427a2ca9e869 Mon Sep 17 00:00:00 2001 From: Nick Vatamaniuc Date: Fri, 26 Apr 2024 19:11:55 -0400 Subject: [PATCH] Fix invalid call to exit/2 in couch_server Previously we called it as `exit(couch_server_N, config_change)` but exit/2 doesn't know what to do with an atom, it needs a pid. ``` exit(couch_server_1, foo). ** exception error: bad argument in function exit/2 called as exit(couch_server_1,foo) *** argument 1: not a pid ``` This doesn't actually restart the servers as intended and it's also making quite a mess in the eunit logs. In addition to ensuring we're calling a Pid, use a `{shutdown, _}` error shape to avoid triggering verbose SASL report as it's an expected condition. --- src/couch/src/couch_server.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl index 384f9d3088d..623b5de2e7e 100644 --- a/src/couch/src/couch_server.erl +++ b/src/couch/src/couch_server.erl @@ -335,7 +335,10 @@ terminate(Reason, Srv) -> ok. handle_config_change("couchdb", "database_dir", _, _, N) -> - exit(couch_server(N), config_change), + case whereis(couch_server(N)) of + Pid when is_pid(Pid) -> exit(Pid, {shutdown, config_change}); + undefined -> ok + end, remove_handler; handle_config_change("couchdb", "update_lru_on_read", "true", _, N) -> gen_server:call(couch_server(N), {set_update_lru_on_read, true}), @@ -719,8 +722,8 @@ handle_cast({close_db_if_idle, DbName}, Server) -> handle_cast(Msg, Server) -> {stop, {unknown_cast_message, Msg}, Server}. -handle_info({'EXIT', _Pid, config_change}, Server) -> - {stop, config_change, Server}; +handle_info({'EXIT', _Pid, {shutdown, config_change}}, Server) -> + {stop, {shutdown, config_change}, Server}; handle_info({'EXIT', Pid, Reason}, Server) -> case ets:lookup(couch_dbs_pid_to_name(Server), Pid) of [{Pid, DbName}] ->