Skip to content

Commit

Permalink
Don't use MySQL read / write timeout options
Browse files Browse the repository at this point in the history
The model for async is different to the sync client.  Timeouts are
expected to be handled by the calling application rather than the client
library.
  • Loading branch information
ndptech committed Jun 20, 2024
1 parent 4a5d2c9 commit 104dfa2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
2 changes: 1 addition & 1 deletion raddb/mods-available/sql
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ sql {
# logfile = ${logdir}/sqllog.sql

#
# query_timeout:: Set the maximum query duration for `mysql` and `cassandra`.
# query_timeout:: Set the maximum query duration for `cassandra`.
#
# query_timeout = 5

Expand Down
26 changes: 0 additions & 26 deletions src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,32 +290,6 @@ static connection_state_t _sql_connection_init(void **h, connection_t *conn, voi
mysql_options(&(c->db), MYSQL_OPT_RECONNECT, &reconnect);
}

if (fr_time_delta_ispos(config->query_timeout)) {
unsigned int read_timeout = fr_time_delta_to_sec(config->query_timeout);
unsigned int write_timeout = fr_time_delta_to_sec(config->query_timeout);

/*
* The timeout in seconds for each attempt to read from the server.
* There are retries if necessary, so the total effective timeout
* value is three times the option value.
*/
if (read_timeout >= 3) read_timeout /= 3;

/*
* The timeout in seconds for each attempt to write to the server.
* There is a retry if necessary, so the total effective timeout
* value is two times the option value.
*/
if (write_timeout >= 2) write_timeout /= 2;

/*
* Connect timeout is actually connect timeout (according to the
* docs) there are no automatic retries.
*/
mysql_options(&(c->db), MYSQL_OPT_READ_TIMEOUT, &read_timeout);
mysql_options(&(c->db), MYSQL_OPT_WRITE_TIMEOUT, &write_timeout);
}

sql_flags = CLIENT_MULTI_RESULTS | CLIENT_FOUND_ROWS;

#ifdef CLIENT_MULTI_STATEMENTS
Expand Down

0 comments on commit 104dfa2

Please sign in to comment.