~percona-core/percona-toolkit/release-2.2.8-v2

« back to all changes in this revision

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

  • Committer: Daniel Nichter
  • Date: 2014-05-30 01:09:13 UTC
  • mfrom: (598.5.6 release-2.2.8)
  • Revision ID: daniel@percona.com-20140530010913-4wep0en37aa4vvok
Merge release-2.2.8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
{
55
55
package Percona::Toolkit;
56
56
 
57
 
our $VERSION = '2.2.7';
 
57
our $VERSION = '2.2.8';
58
58
 
59
59
use strict;
60
60
use warnings FATAL => 'all';
3771
3771
 
3772
3772
   my $dbh = $self->{dbh};
3773
3773
   if ( !$dbh || !$dbh->ping() ) {
3774
 
      if ( $self->{ask_pass} && !$self->{asked_for_pass} ) {
 
3774
      if ( $self->{ask_pass} && !$self->{asked_for_pass} && !defined $dsn->{p}) {
3775
3775
         $dsn->{p} = OptionParser::prompt_noecho("Enter MySQL password: ");
3776
3776
         $self->{asked_for_pass} = 1;
3777
3777
      }
8105
8105
         return;
8106
8106
      };
8107
8107
 
8108
 
      my $get_lag = sub {
8109
 
         my ($cxn) = @_;
8110
 
         my $dbh = $cxn->dbh();
8111
 
         if ( !$dbh || !$dbh->ping() ) {
8112
 
            eval { $dbh = $cxn->connect() };  # connect or die trying
8113
 
            if ( $EVAL_ERROR ) {
8114
 
               $oktorun = 0;  # flag for cleanup tasks
8115
 
               chomp $EVAL_ERROR;
8116
 
               die "Lost connection to replica " . $cxn->name()
8117
 
                  . " while attempting to get its lag ($EVAL_ERROR)\n";
 
8108
      my $get_lag;
 
8109
      # The plugin is able to override the slavelag check so tools like 
 
8110
      # pt-heartbeat or other replicators (Tungsten...) can be used to 
 
8111
      # measure replication lag
 
8112
      if ( $plugin && $plugin->can('get_slave_lag') ) {
 
8113
         $get_lag = $plugin->get_slave_lag(oktorun => \$oktorun);
 
8114
      } else {      
 
8115
         $get_lag = sub {
 
8116
            my ($cxn) = @_;
 
8117
            my $dbh = $cxn->dbh();
 
8118
            if ( !$dbh || !$dbh->ping() ) {
 
8119
               eval { $dbh = $cxn->connect() };  # connect or die trying
 
8120
               if ( $EVAL_ERROR ) {
 
8121
                  $oktorun = 0;  # flag for cleanup tasks
 
8122
                  chomp $EVAL_ERROR;
 
8123
                  die "Lost connection to replica " . $cxn->name()
 
8124
                     . " while attempting to get its lag ($EVAL_ERROR)\n";
 
8125
               }
8118
8126
            }
8119
 
         }
8120
 
         return $ms->get_slave_lag($dbh);
8121
 
      };
8122
 
 
 
8127
            return $ms->get_slave_lag($dbh);
 
8128
         };
 
8129
      }
 
8130
      
8123
8131
      $replica_lag = new ReplicaLagWaiter(
8124
8132
         slaves   => $slave_lag_cxns,
8125
8133
         max_lag  => $o->get('max-lag'),
11345
11353
   after_drop_old_table
11346
11354
   before_drop_triggers
11347
11355
   before_exit
 
11356
   get_slave_lag
11348
11357
 
11349
11358
Each hook is passed different arguments.  To see which arguments are passed
11350
11359
to a hook, search for the hook's name in the tool's source code, like: