summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMike Griffin <mg@webmail.us>2022-07-29 16:07:42 +1000
committerDaniel Black <daniel@mariadb.org>2022-08-02 20:31:08 +1000
commit53c4e4d054cb5ac895535abc9815e70378dbf1b5 (patch)
treed483afede383efe63772d54b7055cb6a15c786f1 /client
parent5ac528a91f2d8a3b84e83b434b08fa9dc428f80c (diff)
downloadmariadb-git-53c4e4d054cb5ac895535abc9815e70378dbf1b5.tar.gz
MDEV-18702 mysqldump: add variable 'max-statement-time'
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=DEFAULT (28800). 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. Reviewer and test case author Daniel Black
Diffstat (limited to 'client')
-rw-r--r--client/mysqldump.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 6cdc3db3c08..0d9b48e585e 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -146,6 +146,7 @@ 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 double opt_max_statement_time= 0.0;
static MYSQL mysql_connection,*mysql=0;
static DYNAMIC_STRING insert_pat, select_field_names;
static char *opt_password=0,*current_user=0,
@@ -162,6 +163,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 +466,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,
@@ -6816,6 +6822,7 @@ static void dynstr_realloc_checked(DYNAMIC_STRING *str, ulong additional_size)
int main(int argc, char **argv)
{
+ char query[48];
char bin_log_name[FN_REFLEN];
int exit_code;
int consistent_binlog_pos= 0;
@@ -6857,6 +6864,13 @@ int main(int argc, char **argv)
if (!path)
write_header(md_result_file, *argv);
+ /* Set MAX_STATEMENT_TIME to 0 unless set in client */
+ 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)
{