Merge lp:~percona-toolkit-dev/percona-toolkit/fix-lock-wait-timeout-bug-946776.

This commit is contained in:
Daniel Nichter
2012-03-06 12:30:58 -07:00

View File

@@ -5940,29 +5940,37 @@ sub main {
. "level to REPEATABLE-READ.\n";
}
# We set innodb_lock_wait_timeout=1 so that if this tool happens to cause
# some locking, it will be more likely to be the victim than other
# connections to the server, and thus disrupt the server less.
$sql = 'SHOW SESSION VARIABLES LIKE "innodb_lock_wait_timeout"';
PTDEBUG && _d($dbh, $sql);
my (undef, $lock_wait_timeout) = $dbh->selectrow_array($sql);
PTDEBUG && _d('innodb_lock_wait_timeout', $lock_wait_timeout);
if ( ($lock_wait_timeout || 0) > $o->get('lock-wait-timeout') ) {
$sql = 'SET SESSION innodb_lock_wait_timeout=1';
eval {
PTDEBUG && _d($dbh, $sql);
$dbh->do($sql);
};
if ( $EVAL_ERROR ) {
warn "Failed to $sql: $EVAL_ERROR\n"
# We set innodb_lock_wait_timeout=1 (the option's default value)
# so that if this tool happens to cause some locking, it will more
# likely be the victim than other connections and thus avoid disrupting
# the server. The var is only dynamic with the InnoDB plugin, so
# if setting it fails we only warn if the server's value is greater
# than the desired value. E.g. if user does --lock-wait-timeout 5
# and the set fails but the server's value is 1, then that's ok, but
# if the server's value is 10, then that's not ok.
my $lock_wait_timeout = $o->get('lock-wait-timeout');
my $set_lwt = "SET SESSION innodb_lock_wait_timeout=$lock_wait_timeout";
PTDEBUG && _d($dbh, $set_lwt);
eval {
$dbh->do($set_lwt);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
# Get the server's current value.
$sql = "SHOW SESSION VARIABLES LIKE 'innodb_lock_wait_timeout'";
PTDEBUG && _d($dbh, $sql);
my (undef, $curr_lwt) = $dbh->selectrow_array($sql);
PTDEBUG && _d('innodb_lock_wait_timeout on server:', $curr_lwt);
if ( $curr_lwt > $lock_wait_timeout ) {
warn "Failed to $set_lwt: $EVAL_ERROR\n"
. "The current innodb_lock_wait_timeout value "
. "$lock_wait_timeout is higher than the --lock-wait-timeout "
. "value " . $o->get('lock-wait-timeout') . " and the variable "
. "cannot be changed. innodb_lock_wait_timeout is only dynamic "
. "when using the InnoDB plugin. To prevent this warning, either "
. "specify --lock-wait-time=$lock_wait_timeout, or manually "
. "set innodb_lock_wait_timeout to a value less than or equal "
. "to " . $o->get('lock-wait-timeout') . " and restart MySQL.\n";
. "$curr_lwt is greater than the --lock-wait-timeout "
. "value $lock_wait_timeout and the variable cannot be "
. "changed. innodb_lock_wait_timeout is only dynamic when "
. "using the InnoDB plugin. To prevent this warning, either "
. "specify --lock-wait-time=$curr_lwt, or manually set "
. "innodb_lock_wait_timeout to a value less than or equal "
. "to $lock_wait_timeout and restart MySQL.\n";
}
}
};
@@ -7989,10 +7997,13 @@ Ignore tables whose names match the Perl regex.
type: int; default: 1
Set the session value of the innodb_lock_wait_timeout variable on the master host.
Setting this option dynamically requires the InnoDB plugin, so this works only
on newer InnoDB and MySQL versions. This option helps guard against long lock
waits if the checksum queries become slow for some reason.
Set the session value of C<innodb_lock_wait_timeout> on the master host.
This option helps guard against long lock waits if the checksum queries
become slow for some reason. Setting this option dynamically requires the
InnoDB plugin, so this works only on newer InnoDB and MySQL versions. If
setting the value fails and the current server value is greater than the
specified value, then a warning is printed; else, if the current server
value is less than or equal to the specified value, no warning is printed.
=item --max-lag