diff options
author | Mike Griffin <mg@webmail.us> | 2022-07-29 16:07:42 +1000 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2022-07-29 20:19:45 +1000 |
commit | d51d2c1cc5402e9de84ee38492786d2ba30154f7 (patch) | |
tree | aa9aaaffe3edec71185e8914cef328e468e1b9fd | |
parent | cbcc0101ee3016b398490685d30db296b1892db7 (diff) | |
download | mariadb-git-bb-10.3-danielblack-MDEV-18702.tar.gz |
MDEV-18702 mysqldump: add variable 'max-statement-time'bb-10.3-danielblack-MDEV-18702
With a global non-default max-statement-time of a time interval that exceed
the query time mysqldump queries when doing a backup.
To solve both, add a max-statement-time option, defaulting to 0 (unlimited time).
Also like mariabackup, set the session wait_timeout=2147483. The
time/processing between mysqldump times isn't expected to get that
close ever, but let's adopt the standard of mariabackup as no-one has
challenged it has having a detrimental effect.
-rw-r--r-- | client/mysqldump.c | 17 | ||||
-rw-r--r-- | man/mysqldump.1 | 30 |
2 files changed, 46 insertions, 1 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c index 6cdc3db3c08..e9da2112e81 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -145,7 +145,9 @@ static TYPELIB opt_system_types= static ulonglong opt_system= 0ULL; static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0, select_field_names_inited= 0; -static ulong opt_max_allowed_packet, opt_net_buffer_length; +static ulong opt_max_allowed_packet; +static double opt_max_statement_time= 0.0; +static ulong opt_net_buffer_length; static MYSQL mysql_connection,*mysql=0; static DYNAMIC_STRING insert_pat, select_field_names; static char *opt_password=0,*current_user=0, @@ -162,6 +164,7 @@ static my_bool server_supports_switching_charsets= TRUE; static ulong opt_compatible_mode= 0; #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2 +#define MYSQL_OPT_MAX_STATEMENT_TIME 0 #define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2 static uint opt_mysql_port= 0, opt_master_data; @@ -464,6 +467,10 @@ static struct my_option my_long_options[] = &opt_max_allowed_packet, &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, (longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, + {"max-statement-time", MYSQL_OPT_MAX_STATEMENT_TIME, + "Max statement execution time. If unset, overrides server default with 0.", + &opt_max_statement_time, &opt_max_statement_time, 0, GET_DOUBLE, + REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "The buffer size for TCP/IP and socket communication.", &opt_net_buffer_length, &opt_net_buffer_length, 0, @@ -6857,6 +6864,14 @@ int main(int argc, char **argv) if (!path) write_header(md_result_file, *argv); + /* Set MAX_STATEMENT_TIME to 0 unless set in client */ + char query[48]; + my_snprintf(query, sizeof(query), "/*!100100 SET @@MAX_STATEMENT_TIME=%f */", opt_max_statement_time); + mysql_query(mysql, query); + + /* Set server side timeout between client commands to server compiled-in default */ + mysql_query(mysql, "/*!100100 SET WAIT_TIMEOUT=DEFAULT */"); + /* Check if the server support multi source */ if (mysql_get_server_version(mysql) >= 100000) { diff --git a/man/mysqldump.1 b/man/mysqldump.1 index ae6d76f24c3..140bc45c7c6 100644 --- a/man/mysqldump.1 +++ b/man/mysqldump.1 @@ -1361,6 +1361,21 @@ Sets the maximum packet length to send to or receive from server\&. .sp -1 .IP \(bu 2.3 .\} +.\" mysqldump: max-statement-time option +.\" max-statement-time option: mysqldump +\fB\-\-max\-statement\-time=\fR\fB\fIseconds\fR\fR +.sp +Sets the maximum time any statement can run before being timed out by the server. (Default value is 0 (no limit))\& +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} .\" mysqldump: net-buffer-length option .\" net-buffer-length option: mysqldump \fB\-\-net\-buffer\-length=\fR\fB\fIlength\fR\fR @@ -2619,6 +2634,21 @@ The maximum size of the buffer for client/server communication\&. The maximum is .sp -1 .IP \(bu 2.3 .\} +max_statement_time +.sp +A query that has taken more than max_statement_time seconds will be aborted and the backup will +fail\&. The argument will be treated as a decimal value with microsecond precision\&. A value +of 0 (default) means no timeout\&. The maximum timeout is 31536000 seconds\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} net_buffer_length .sp The initial size of the buffer for client/server communication\&. When creating multiple\-row |