diff options
| author | Paweł Chmielowski <pawel@process-one.net> | 2022-07-19 14:35:35 +0200 |
|---|---|---|
| committer | Paweł Chmielowski <pawel@process-one.net> | 2022-07-19 14:35:35 +0200 |
| commit | 7b944444ce955d493bc49d504b91e436e7b4a895 (patch) | |
| tree | 1b5f60aefe5c10c09e891215de05356b2d0b7f06 | |
| parent | Make first sql reconnect wait shorter time (diff) | |
Catch mysql connection being close earlier
| -rw-r--r-- | rebar.config | 2 | ||||
| -rw-r--r-- | src/ejabberd_sql.erl | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/rebar.config b/rebar.config index 6db4fe2fc..d0b009848 100644 --- a/rebar.config +++ b/rebar.config @@ -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"}}}}, diff --git a/src/ejabberd_sql.erl b/src/ejabberd_sql.erl index 7f31668d2..1e32a87c8 100644 --- a/src/ejabberd_sql.erl +++ b/src/ejabberd_sql.erl @@ -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), |
