diff --git a/src/epgsql.app.src b/src/epgsql.app.src index 74d84d8..dcda5ee 100644 --- a/src/epgsql.app.src +++ b/src/epgsql.app.src @@ -1,6 +1,6 @@ {application, epgsql, [{description, "PostgreSQL Client"}, - {vsn, "4.7.1.1"}, + {vsn, "4.7.1.2"}, {modules, []}, {registered, []}, {applications, [kernel, diff --git a/src/epgsql_sock.erl b/src/epgsql_sock.erl index a7862fc..ad81eb7 100644 --- a/src/epgsql_sock.erl +++ b/src/epgsql_sock.erl @@ -307,7 +307,7 @@ handle_info({Passive, Sock}, #state{sock = Sock} = State) handle_info({Closed, Sock}, #state{sock = Sock} = State) when Closed == tcp_closed; Closed == ssl_closed -> - {stop, sock_closed, flush_queue(State#state{sock = undefined}, {error, sock_closed})}; + {stop, {shutdown, sock_closed}, flush_queue(State#state{sock = undefined}, {error, sock_closed})}; handle_info({Error, Sock, Reason}, #state{sock = Sock} = State) when Error == tcp_error; Error == ssl_error -> @@ -408,8 +408,9 @@ command_exec(Transport, Command, CmdState, State) -> _ -> {noreply, finish(State2, Result)} end; - {stop, StopReason, Response, State1} -> + {stop, StopReason0, Response, State1} -> reply(Transport, Response, Response), + StopReason = maybe_silence_reason(StopReason0), {stop, StopReason, State1} end. @@ -831,6 +832,12 @@ handle_xlog_data(StartLSN, EndLSN, WALRecord, redact_state(State) -> State#state{rows = information_redacted}. +%% Avoid spamming logs with crash reports for potentially transient failures. +maybe_silence_reason(econnrefused = Reason) -> + {shutdown, Reason}; +maybe_silence_reason(Reason) -> + Reason. + -ifdef(TEST). state_to_map(State) -> diff --git a/test/epgsql_SUITE.erl b/test/epgsql_SUITE.erl index ae38197..cbaecfe 100644 --- a/test/epgsql_SUITE.erl +++ b/test/epgsql_SUITE.erl @@ -462,7 +462,7 @@ connect_to_closed_port(Config) -> "epgsql_test", "epgsql_test", [{port, Port + 1}, {database, "epgsql_test_db1"}])), - ?assertMatch({'EXIT', _, econnrefused}, receive Stop -> Stop end), + ?assertMatch({'EXIT', _, {shutdown, econnrefused}}, receive Stop -> Stop end), process_flag(trap_exit, Trap). prepared_query(Config) ->