diff --git a/bin/pt-archiver b/bin/pt-archiver index f3e22b72..680cfec9 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -4728,6 +4728,7 @@ sub _touch { sysopen my $fh, $file, O_WRONLY|O_CREAT|O_NONBLOCK or die "Cannot create $file : $!"; close $fh or die "Cannot close $file : $!"; + utime(undef, undef, $file); } sub encode_client_response { @@ -4801,7 +4802,7 @@ my @beginning_of_txn; my $q = new Quoter; sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package # Reset global vars else tests, which run this tool as a module, # may encounter weird results. @@ -5287,6 +5288,14 @@ sub main { }); } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($src->{dbh}); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + # ######################################################################## # Start archiving. # ######################################################################## diff --git a/bin/pt-config-diff b/bin/pt-config-diff index e384c31f..6d4bddfc 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -3887,7 +3887,7 @@ use Percona::Toolkit; use constant PTDEBUG => $ENV{PTDEBUG} || 0; sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package # ######################################################################## # Get configuration information. @@ -3971,6 +3971,14 @@ sub main { $daemon->make_PID_file(); } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($configs[0]->{dbh}); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + # ######################################################################### # Diff the given configs. # ######################################################################### diff --git a/bin/pt-deadlock-logger b/bin/pt-deadlock-logger index 3e8833cb..948061a0 100755 --- a/bin/pt-deadlock-logger +++ b/bin/pt-deadlock-logger @@ -3392,7 +3392,7 @@ my %is_proc_info = ( ); sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package my $q = new Quoter(); @@ -3439,7 +3439,7 @@ sub main { $o->usage_or_errors(); # ######################################################################## - # Start working. + # Connect to MySQL and set up the --dest, if any. # ######################################################################## my $dbh = get_cxn($source_dsn, 1); my $dest_dbh; @@ -3481,7 +3481,9 @@ sub main { } } + # ######################################################################## # Daemonize only after (potentially) asking for passwords for --ask-pass. + # ######################################################################## my $daemon; if ( $o->get('daemonize') ) { $daemon = new Daemon(o=>$o); @@ -3494,6 +3496,17 @@ sub main { $daemon->make_PID_file(); } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + + # ######################################################################## + # Start looking for and logging deadlocks. + # ######################################################################## my $last_fingerprint = ''; $oktorun = 1; diff --git a/bin/pt-diskstats b/bin/pt-diskstats index 286ab3b3..367e6fe0 100755 --- a/bin/pt-diskstats +++ b/bin/pt-diskstats @@ -4483,7 +4483,17 @@ sub main { $o->usage_or_errors(); + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check(); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + + # ######################################################################## # Interactive mode. Delegate to DiskstatsMenu::run_interactive + # ######################################################################## my $diskstats = new DiskstatsMenu(); return $diskstats->run_interactive( OptionParser => $o, diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 668fd843..affb86a5 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -4304,7 +4304,7 @@ my $hdr_width = $max_width - 2; # for '# ' my $hdr_fmt = "# %-${hdr_width}s\n"; sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package my %summary = ( 'Total Indexes' => 0 ); my %seen_tbl; @@ -4348,6 +4348,14 @@ sub main { my $dbh = $dp->get_dbh($dp->get_cxn_params($dsn), { AutoCommit => 1, }); + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + # ####################################################################### # Do the main work. # ####################################################################### diff --git a/bin/pt-find b/bin/pt-find index 4677c18d..d0e0d025 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -3395,7 +3395,7 @@ my @stored_code_tests = qw( ); sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package # ######################################################################## # Get configuration information. @@ -3516,6 +3516,14 @@ sub main { # Discover if we need to get stored code. Need dbh to do this. my $need_stored_code = grep { $o->got($_); } @stored_code_tests; + + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } # ######################################################################## # Go do it. diff --git a/bin/pt-fk-error-logger b/bin/pt-fk-error-logger index 14fb5310..71d96c1f 100755 --- a/bin/pt-fk-error-logger +++ b/bin/pt-fk-error-logger @@ -3049,7 +3049,8 @@ Transformers->import(qw(parse_timestamp)); my $oktorun; sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package + $oktorun = 1; # ######################################################################## # Get configuration information. @@ -3125,7 +3126,9 @@ sub main { $ins_sth = $dst_dbh->prepare($sql); } + # ######################################################################## # Daemonize only after (potentially) asking for passwords for --ask-pass. + # ######################################################################## my $daemon; if ( $o->get('daemonize') ) { $daemon = new Daemon(o=>$o); @@ -3138,7 +3141,17 @@ sub main { $daemon->make_PID_file(); } - $oktorun = 1; + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + + # ######################################################################## + # Start finding and logging foreign key errors. + # ######################################################################## while ( # Quit if: ($start == $end || $now < $end) # time is exceeded && $oktorun # or instructed to quit diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index 5ded3f71..bf3f9cf9 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -4229,7 +4229,7 @@ my @dbhs; # Holds slave DBHs if --recurse my @sths; # Holds [$host, $sth] if --recurse sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package # Reset all global vars between test runs else weird things happen. @dbhs = (); @@ -4637,6 +4637,14 @@ sub main { return 0; } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + # ######################################################################## # Setup moving averages for --frames. # ######################################################################## diff --git a/bin/pt-index-usage b/bin/pt-index-usage index da43df63..1fb881b3 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -5812,7 +5812,7 @@ Transformers->import(qw(make_checksum)); my $oktorun = 1; sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package $oktorun = 1; @@ -5979,6 +5979,14 @@ sub main { } } } + + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } # ######################################################################## # Populate the IndexUsage object with indexes. Also get a list of all diff --git a/bin/pt-kill b/bin/pt-kill index d1a98c93..9b04b41c 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -5818,7 +5818,7 @@ my $o; # ######################################################################## sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package # ######################################################################## # Get configuration information. @@ -6129,6 +6129,14 @@ sub main { $daemon->make_PID_file(); } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + # ######################################################################## # Start working. # ######################################################################## diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index b5e864a7..cbdf8e87 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -6830,7 +6830,7 @@ $OUTPUT_AUTOFLUSH = 1; sub main { # Reset global vars else tests will fail. - @ARGV = @_; + local @ARGV = @_; $oktorun = 1; @drop_trigger_sqls = (); @@ -7015,6 +7015,14 @@ sub main { die "This tool requires MySQL 5.0.10 or newer.\n"; } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($cxn->dbh()); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + # ######################################################################## # Setup lag and load monitors. # ######################################################################## diff --git a/bin/pt-query-advisor b/bin/pt-query-advisor index da00a4e2..9de001b6 100755 --- a/bin/pt-query-advisor +++ b/bin/pt-query-advisor @@ -7001,7 +7001,7 @@ use sigtrap 'handler', \&sig_int, 'normal-signals'; my $oktorun = 1; # global for sig handler sub main { - @ARGV = @_; # set global ARGV for this package + local @ARGV = @_; # set global ARGV for this package my %seen_id; # already printed rule info (advice) my %seen_fingerprint; # already seen queries @@ -7356,6 +7356,14 @@ sub main { $daemon->make_PID_file(); } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { + Pingback::version_check($dbh); + return 0 if $ENV{PTVCDEBUG} && PTDEBUG; + } + # ######################################################################### # Do it! # ######################################################################### diff --git a/lib/PerconaTest.pm b/lib/PerconaTest.pm index 86f6b4b2..a0370a7b 100644 --- a/lib/PerconaTest.pm +++ b/lib/PerconaTest.pm @@ -81,6 +81,10 @@ eval { our $can_load_data = can_load_data(); +# We do not want every test doing the version-check; +# that would be quite slow. +$ENV{PERCONA_VERSION_CHECK} = 0; + our $dsn_opts = [ { key => 'A', diff --git a/util/update-modules b/util/update-modules index d568c9f3..e57f62da 100755 --- a/util/update-modules +++ b/util/update-modules @@ -120,6 +120,7 @@ update_tool_header() { return 1 fi cat $tool_file-header $tool_file-code > $tool_file + [ $? -eq 0 ] && rm $tool_file-header $tool_file-code } # ############################################################################