Skip to content

Commit

Permalink
Add mysqldump support for logical read ahead
Browse files Browse the repository at this point in the history
Summary:
Adds options to mysqldump:
	--lra-size=X
	--lra-sleep=X
	--lra-n-node-recs-before-sleep=X

These just inject SET statements to set these session variables.

Test Plan:
Ran the mysqldump test on mysqld WITHOUT logical_read_ahead:

--lra-size=5
	Failed on "SET innodb_lra_size=5" with unknown variable:

	mysqldump: Couldn't execute 'SET innodb_lra_size=5':
	Unknown system variable 'innodb_lra_size' (1193)

--lra-size=5 --lra-sleep=10
	Failed on "SET innodb_lra_size=5" with unknown variable:

	mysqldump: Couldn't execute 'SET innodb_lra_size=5':
	Unknown system variable 'innodb_lra_size' (1193)

--lra-sleep=10
	Worked (passed nothing) - forced the code to send anyway, and got:
	mysqldump: Couldn't execute 'SET innodb_lra_sleep=10':
	Unknown system variable 'innodb_lra_sleep' (1193)

	...and likewise for --lra-n-node-recs-before-sleep=X

Ran all of this on mysqld WITH logical_read_ahead:
	Tests all passed without error.

Reviewers: nizamordulu

Reviewed By: nizamordulu
  • Loading branch information
steaphangreene committed Jun 4, 2013
1 parent f8e3619 commit f69a4ea
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/client_priv.h
Expand Up @@ -101,6 +101,7 @@ enum options_client
OPT_ENABLE_CLEARTEXT_PLUGIN,
OPT_TIMEOUT,
OPT_INNODB_OPTIMIZE_KEYS,
OPT_LRA_SIZE, OPT_LRA_SLEEP, OPT_LRA_N_NODE_RECS_BEFORE_SLEEP,
OPT_MAX_CLIENT_OPTION
};

Expand Down
37 changes: 37 additions & 0 deletions client/mysqldump.c
Expand Up @@ -143,6 +143,9 @@ static char compatible_mode_normal_str[255];
static my_bool server_supports_switching_charsets= TRUE;
static ulong opt_compatible_mode= 0;
static ulong opt_timeout = 0;
static ulong opt_lra_size = 0;
static ulong opt_lra_sleep = 0;
static ulong opt_lra_n_node_recs_before_sleep = 0;
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
Expand Down Expand Up @@ -417,6 +420,18 @@ static struct my_option my_long_options[] =
{"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.",
&log_error_file, &log_error_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lra_size", OPT_LRA_SIZE,
"Set innodb_lra_size for the session of this dump.",
&opt_lra_size, &opt_lra_size, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 16384, 0,
0, 0},
{"lra_sleep", OPT_LRA_SLEEP,
"Set innodb_lra_sleep for the session of this dump.",
&opt_lra_sleep, &opt_lra_sleep, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1000, 0,
0, 0},
{"lra_n_node_recs_before_sleep", OPT_LRA_N_NODE_RECS_BEFORE_SLEEP,
"Set innodb_lra_n_node_recs_before_sleep for the session of this dump.",
&opt_lra_n_node_recs_before_sleep, &opt_lra_n_node_recs_before_sleep,
0, GET_ULONG, REQUIRED_ARG, 1024, 128, ULONG_MAX, 0, 0, 0},
{"master-data", OPT_MASTER_DATA,
"This causes the binary log position and filename to be appended to the "
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
Expand Down Expand Up @@ -1610,6 +1625,28 @@ static int connect_to_db(char *host, char *user,char *passwd)
DBUG_RETURN(1);
}

if (opt_lra_size)
{
my_snprintf(buff, sizeof(buff), "SET innodb_lra_size=%lu", opt_lra_size);
if (mysql_query_with_error_report(mysql, 0, buff))
DBUG_RETURN(1);
if (opt_lra_sleep)
{
my_snprintf(buff, sizeof(buff), "SET innodb_lra_sleep=%lu",
opt_lra_sleep);
if (mysql_query_with_error_report(mysql, 0, buff))
DBUG_RETURN(1);
}
if (opt_lra_n_node_recs_before_sleep)
{
my_snprintf(buff, sizeof(buff),
"SET innodb_lra_n_node_recs_before_sleep=%lu",
opt_lra_n_node_recs_before_sleep);
if (mysql_query_with_error_report(mysql, 0, buff))
DBUG_RETURN(1);
}
}

/*
set time_zone to UTC to allow dumping date types between servers with
different time zone settings
Expand Down

0 comments on commit f69a4ea

Please sign in to comment.