mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-27 07:54:58 +00:00
Do check for MySQL restart first in case GET /config is slow. Increase margin to 5s.
This commit is contained in:
15
bin/pt-agent
15
bin/pt-agent
@@ -5944,6 +5944,11 @@ sub run_agent {
|
|||||||
my $services = {};
|
my $services = {};
|
||||||
my $slept = 0;
|
my $slept = 0;
|
||||||
while ( $_oktorun->() ) {
|
while ( $_oktorun->() ) {
|
||||||
|
check_if_mysql_restarted(
|
||||||
|
Cxn => $cxn,
|
||||||
|
slept => $slept,
|
||||||
|
);
|
||||||
|
|
||||||
($config, $lib_dir, $new_daemon, $success) = get_config(
|
($config, $lib_dir, $new_daemon, $success) = get_config(
|
||||||
link => $agent->links->{config},
|
link => $agent->links->{config},
|
||||||
agent => $agent,
|
agent => $agent,
|
||||||
@@ -5954,11 +5959,6 @@ sub run_agent {
|
|||||||
quiet => $state->{first_config},
|
quiet => $state->{first_config},
|
||||||
);
|
);
|
||||||
|
|
||||||
check_if_mysql_restarted(
|
|
||||||
Cxn => $cxn,
|
|
||||||
slept => $slept,
|
|
||||||
);
|
|
||||||
|
|
||||||
# Get services only if we successfully got the config because the services
|
# Get services only if we successfully got the config because the services
|
||||||
# may depened on the current config, specifically the --spool dir.
|
# may depened on the current config, specifically the --spool dir.
|
||||||
if ( $success && $config && $config->links->{services} ) {
|
if ( $success && $config && $config->links->{services} ) {
|
||||||
@@ -8429,6 +8429,7 @@ sub check_if_mysql_restarted {
|
|||||||
|
|
||||||
# Optional args
|
# Optional args
|
||||||
my $uptime = $args{uptime}; # for testing
|
my $uptime = $args{uptime}; # for testing
|
||||||
|
my $margin = $args{margin} || 5;
|
||||||
|
|
||||||
if ( !$uptime ) {
|
if ( !$uptime ) {
|
||||||
$logger->info("Connecting to MySQL");
|
$logger->info("Connecting to MySQL");
|
||||||
@@ -8472,9 +8473,9 @@ sub check_if_mysql_restarted {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $uptime_should_be = $state->{last_uptime} + $slept;
|
my $uptime_should_be = $state->{last_uptime} + $slept;
|
||||||
my $mysql_restarted = $uptime > ($uptime_should_be - 3) && $uptime < ($uptime_should_be + 3) ? 0 : 1;
|
my $mysql_restarted = $uptime > ($uptime_should_be - $margin) && $uptime < ($uptime_should_be + $margin) ? 0 : 1;
|
||||||
$logger->info("Last uptime: $state->{last_uptime} Interval: $slept Uptime should be: $uptime_should_be "
|
$logger->info("Last uptime: $state->{last_uptime} Interval: $slept Uptime should be: $uptime_should_be "
|
||||||
. "Uptime: $uptime MySQL restarted: $mysql_restarted");
|
. "+/- ${margin}s Uptime: $uptime MySQL restarted: $mysql_restarted");
|
||||||
if ( $mysql_restarted ) {
|
if ( $mysql_restarted ) {
|
||||||
$state->{mysql_restarted} = 1;
|
$state->{mysql_restarted} = 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user