fix(pgsql connector): better msg when failing to remove statement
This commit is contained in:
parent
336089f8a7
commit
2956e849eb
|
@ -654,8 +654,8 @@ prepare_sql_to_conn(Conn, Prepares) ->
|
||||||
|
|
||||||
prepare_sql_to_conn(Conn, [], Statements, _Attempts) when is_pid(Conn) ->
|
prepare_sql_to_conn(Conn, [], Statements, _Attempts) when is_pid(Conn) ->
|
||||||
{ok, Statements};
|
{ok, Statements};
|
||||||
prepare_sql_to_conn(Conn, [{Key, _} | _Rest], _Statements, _MaxAttempts = 3) when is_pid(Conn) ->
|
prepare_sql_to_conn(Conn, [{Key, _} | _Rest], _Statements, _MaxAttempts = 2) when is_pid(Conn) ->
|
||||||
{error, {failed_to_remove_prev_prepared_statement, Key}};
|
failed_to_remove_prev_prepared_statement_error();
|
||||||
prepare_sql_to_conn(
|
prepare_sql_to_conn(
|
||||||
Conn, [{Key, {SQL, _RowTemplate}} | Rest] = ToPrepare, Statements, Attempts
|
Conn, [{Key, {SQL, _RowTemplate}} | Rest] = ToPrepare, Statements, Attempts
|
||||||
) when is_pid(Conn) ->
|
) when is_pid(Conn) ->
|
||||||
|
@ -692,11 +692,12 @@ prepare_sql_to_conn(
|
||||||
?SLOG(warning, LogMsg),
|
?SLOG(warning, LogMsg),
|
||||||
case epgsql:close(Conn, statement, Key) of
|
case epgsql:close(Conn, statement, Key) of
|
||||||
ok ->
|
ok ->
|
||||||
?SLOG(info, #{msg => "pqsql_closed_statement_successfully"});
|
?SLOG(info, #{msg => "pqsql_closed_statement_successfully"}),
|
||||||
|
prepare_sql_to_conn(Conn, ToPrepare, Statements, Attempts + 1);
|
||||||
{error, CloseError} ->
|
{error, CloseError} ->
|
||||||
?SLOG(warning, #{msg => "pqsql_close_statement_failed", cause => CloseError})
|
?SLOG(error, #{msg => "pqsql_close_statement_failed", cause => CloseError}),
|
||||||
end,
|
failed_to_remove_prev_prepared_statement_error()
|
||||||
prepare_sql_to_conn(Conn, ToPrepare, Statements, Attempts + 1);
|
end;
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
TranslatedError = translate_to_log_context(Error),
|
TranslatedError = translate_to_log_context(Error),
|
||||||
LogMsg =
|
LogMsg =
|
||||||
|
@ -708,6 +709,13 @@ prepare_sql_to_conn(
|
||||||
{error, export_error(TranslatedError)}
|
{error, export_error(TranslatedError)}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
failed_to_remove_prev_prepared_statement_error() ->
|
||||||
|
Msg =
|
||||||
|
("A previous prepared statement for the action already exists and "
|
||||||
|
"we are not able to close it. Please, try to disable and then enable "
|
||||||
|
"the connector to resolve this issue."),
|
||||||
|
{error, unicode:charactes_to_binary(Msg)}.
|
||||||
|
|
||||||
to_bin(Bin) when is_binary(Bin) ->
|
to_bin(Bin) when is_binary(Bin) ->
|
||||||
Bin;
|
Bin;
|
||||||
to_bin(Atom) when is_atom(Atom) ->
|
to_bin(Atom) when is_atom(Atom) ->
|
||||||
|
|
Loading…
Reference in New Issue