Catch mysql connection being close earlier

This commit is contained in:
Paweł Chmielowski 2022-07-19 14:35:35 +02:00
parent 73167ef1bd
commit 7b944444ce
2 changed files with 5 additions and 2 deletions

View File

@ -56,7 +56,7 @@
{mqtree, ".*", {git, "https://github.com/processone/mqtree", {tag, "1.0.15"}}},
{p1_acme, ".*", {git, "https://github.com/processone/p1_acme", {tag, "1.0.19"}}},
{if_var_true, mysql,
{p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql", {tag, "1.0.19"}}}},
{p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql", "82b68eb59a2e5a042605c604f72433c3472d5cf3"}}},
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.11"}}},
{if_var_true, pgsql,
{p1_pgsql, ".*", {git, "https://github.com/processone/p1_pgsql", {tag, "1.1.18"}}}},

View File

@ -684,7 +684,7 @@ sql_query_internal(Query) ->
mysql ->
mysql_to_odbc(p1_mysql_conn:squery(State#state.db_ref,
[Query], self(),
[{QueryTimeout - 1000},
[{timeout, QueryTimeout - 1000},
{result_type, binary}]));
sqlite ->
Host = State#state.host,
@ -869,6 +869,9 @@ sql_rollback() ->
abort_on_driver_error({error, <<"query timed out">>} = Reply, From, Timestamp) ->
reply(From, Reply, Timestamp),
{stop, timeout, get(?STATE_KEY)};
abort_on_driver_error({error, <<"connection closed">>} = Reply, From, Timestamp) ->
reply(From, Reply, Timestamp),
handle_reconnect(<<"connection closed">>, get(?STATE_KEY));
abort_on_driver_error({error, <<"Failed sending data on socket", _/binary>>} = Reply,
From, Timestamp) ->
reply(From, Reply, Timestamp),