~percona-toolkit-dev/percona-toolkit/fix-1156901-skip-retry-check-for-repl-threads

« back to all changes in this revision

Viewing changes to bin/pt-online-schema-change

  • Committer: Daniel Nichter
  • Date: 2013-03-20 17:53:36 UTC
  • Revision ID: daniel@percona.com-20130320175336-20jab8wqbjvltbw2
Tags: 2.2.1
Hot-fix --version-check.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7062
7062
   my $vc_file   = $args{vc_file} || version_check_file();
7063
7063
   PTDEBUG && _d('Updating last check time:', $now);
7064
7064
 
 
7065
   my %all_instances = map {
 
7066
      $_->{id} => { name => $_->{name}, ts => $now }
 
7067
   } @$instances;
 
7068
 
 
7069
   if ( -f $vc_file ) {
 
7070
      open my $fh, '<', $vc_file or die "Cannot read $vc_file: $OS_ERROR";
 
7071
      my $contents = do { local $/ = undef; <$fh> };
 
7072
      close $fh;
 
7073
 
 
7074
      foreach my $line ( split("\n", ($contents || '')) ) {
 
7075
         my ($id, $ts) = split(',', $line);
 
7076
         if ( !exists $all_instances{$id} ) {
 
7077
            $all_instances{$id} = { ts => $ts };  # original ts, not updated
 
7078
         }
 
7079
      }
 
7080
   }
 
7081
 
7065
7082
   open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
7066
 
   foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
7067
 
      PTDEBUG && _d('Updated:', Dumper($instance));
7068
 
      print { $fh } $instance->{id} . ',' . $now . "\n";
 
7083
   foreach my $id ( sort keys %all_instances ) {
 
7084
      PTDEBUG && _d('Updated:', $id, Dumper($all_instances{$id}));
 
7085
      print { $fh } $id . ',' . $all_instances{$id}->{ts} . "\n";
7069
7086
   }
7070
7087
   close $fh;
7071
7088
 
7100
7117
   }
7101
7118
   my $id = md5_hex($name);
7102
7119
 
7103
 
   PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
 
7120
   PTDEBUG && _d('MySQL instance:', $id, $name, Dumper($dsn));
7104
7121
 
7105
7122
   return $name, $id;
7106
7123
}