~percona-toolkit-dev/percona-toolkit/cant-nibble-bug-918056

« back to all changes in this revision

Viewing changes to bin/pt-query-digest

  • Committer: Daniel Nichter
  • Date: 2012-05-23 22:07:05 UTC
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: daniel@percona.com-20120523220705-lpw10rfyx1gqlxrs
Implement retry_on_error for Pipeline processes.  Retry iteration proc twice, then fail completely.  Fix mirror.t.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11745
11745
 
11746
11746
   push @{$self->{procs}}, $process;
11747
11747
   push @{$self->{names}}, $name;
 
11748
   if ( my $n = $args{retry_on_error} ) {
 
11749
      $self->{retries}->{$name} = $n;
 
11750
   }
11748
11751
   if ( $self->{instrument} ) {
11749
11752
      $self->{instrumentation}->{$name} = { time => 0, calls => 0 };
11750
11753
   }
11809
11812
         }
11810
11813
      };
11811
11814
      if ( $EVAL_ERROR ) {
11812
 
         warn "Pipeline process $procno ("
11813
 
            . ($self->{names}->[$procno] || "")
11814
 
            . ") caused an error: $EVAL_ERROR";
11815
 
         die $EVAL_ERROR unless $self->{continue_on_error};
 
11815
         my $name = $self->{names}->[$procno] || "";
 
11816
         my $msg  = "Pipeline process " . ($procno + 1)
 
11817
                  . " ($name) caused an error: "
 
11818
                  . $EVAL_ERROR;
 
11819
         if ( defined $self->{retries}->{$name} ) {
 
11820
            my $n = $self->{retries}->{$name};
 
11821
            if ( $n ) {
 
11822
               warn $msg . "Will retry pipeline process $procno ($name) "
 
11823
                  . "$n more " . ($n > 1 ? "times" : "time") . ".\n";
 
11824
               $self->{retries}->{$name}--;
 
11825
            }
 
11826
            else {
 
11827
               die $msg . "Terminating pipeline because process $procno "
 
11828
                  . "($name) caused too many errors.\n";
 
11829
            }
 
11830
         }
 
11831
         elsif ( !$self->{continue_on_error} ) {
 
11832
            die $msg;
 
11833
         }
 
11834
         else {
 
11835
            warn $msg;
 
11836
         }
11816
11837
      }
11817
11838
   }
11818
11839
 
12562
12583
 
12563
12584
   { # iteration
12564
12585
      $pipeline->add(
12565
 
         name    => 'iteration',
12566
 
         process => sub {
 
12586
         # This is a critical proc: if we die here, we probably need
 
12587
         # to stop, else an infinite loop can develop:
 
12588
         # https://bugs.launchpad.net/percona-toolkit/+bug/888114
 
12589
         # We'll retry twice in case the problem is just one bad
 
12590
         # query class, or something like that.
 
12591
         retry_on_error => 2,
 
12592
         name           => 'iteration',
 
12593
         process        => sub {
12567
12594
            my ( $args ) = @_;
12568
12595
 
12569
12596
            # Start the (next) iteration.