~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-query-digest

  • Committer: Brian Fraser
  • Date: 2013-04-16 14:37:32 UTC
  • Revision ID: fraserbn@gmail.com-20130416143732-8leshs4dbd2wciwt
Processlist.pm: Skip checking for a restarted query if looking at a replication thread

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
# ###########################################################################
82
82
{
83
83
package Lmo::Utils;
 
84
 
84
85
use strict;
85
86
use warnings qw( FATAL all );
86
87
require Exporter;
88
89
 
89
90
BEGIN {
90
91
   @ISA = qw(Exporter);
91
 
   @EXPORT = @EXPORT_OK = qw(_install_coderef _unimport_coderefs _glob_for _stash_for);
 
92
   @EXPORT = @EXPORT_OK = qw(
 
93
      _install_coderef
 
94
      _unimport_coderefs
 
95
      _glob_for
 
96
      _stash_for
 
97
   );
92
98
}
93
99
 
94
100
{
272
278
   return Lmo::Meta->new(class => $class);
273
279
}
274
280
 
275
 
 
276
281
1;
277
282
}
278
283
# ###########################################################################
3210
3215
               $new_query = 1;
3211
3216
            }
3212
3217
            elsif ( $curr->[INFO] && defined $curr->[TIME]
3213
 
                    && $query_start - $etime - $prev->[START] > $fudge ) {
3214
 
               PTDEBUG && _d('Query restarted; new query',
3215
 
                  $query_start, $etime, $prev->[START], $fudge);
3216
 
               $new_query = 1;
 
3218
                    && $query_start - $etime - $prev->[START] > $fudge)
 
3219
            {
 
3220
               my $ms = $self->{MasterSlave};
 
3221
               
 
3222
               my $is_repl_thread = !$ms->is_replication_thread({
 
3223
                                        Command => $curr->[COMMAND],
 
3224
                                        User    => $curr->[USER],
 
3225
                                        State   => $curr->[STATE],
 
3226
                                        Id      => $curr->[ID]});
 
3227
               if ( !$is_repl_thread ) {
 
3228
                  PTDEBUG && _d('Query restarted; new query',
 
3229
                     $query_start, $etime, $prev->[START], $fudge);
 
3230
                  $new_query = 1;
 
3231
               }
 
3232
               elsif ( PTDEBUG ) {
 
3233
                  _d(q'Query has a start time beyond the fudge factor, ',
 
3234
                     q'but not counting it as a new query because, ',
 
3235
                     q{it's a replication thread});
 
3236
               }
3217
3237
            }
3218
3238
 
3219
3239
            if ( $new_query ) {
3789
3809
      sessions       => {},
3790
3810
      o              => $args{o},
3791
3811
      fake_thread_id => 2**32,   # see _make_event()
 
3812
      null_event     => $args{null_event},
3792
3813
   };
3793
3814
   PTDEBUG && $self->{server} && _d('Watching only server', $self->{server});
3794
3815
   return bless $self, $class;
3809
3830
      $server .= ":$self->{port}";
3810
3831
      if ( $src_host ne $server && $dst_host ne $server ) {
3811
3832
         PTDEBUG && _d('Packet is not to or from', $server);
3812
 
         return;
 
3833
         return $self->{null_event};
3813
3834
      }
3814
3835
   }
3815
3836
 
3825
3846
   }
3826
3847
   else {
3827
3848
      PTDEBUG && _d('Packet is not to or from a MySQL server');
3828
 
      return;
 
3849
      return $self->{null_event};
3829
3850
   }
3830
3851
   PTDEBUG && _d('Client', $client);
3831
3852
 
3843
3864
      else {
3844
3865
         PTDEBUG && _d('Ignoring mid-stream', $packet_from, 'data,',
3845
3866
            'packetno', $packetno);
3846
 
         return;
 
3867
         return $self->{null_event};
3847
3868
      }
3848
3869
 
3849
3870
      $self->{sessions}->{$client} = {
3886
3907
         delete $self->{sessions}->{$session->{client}};
3887
3908
         return $event;
3888
3909
      }
3889
 
      return;
 
3910
      return $self->{null_event};
3890
3911
   }
3891
3912
 
3892
3913
   if ( $session->{compress} ) {
3912
3933
         PTDEBUG && _d('remove_mysql_header() failed; failing session');
3913
3934
         $session->{EVAL_ERROR} = $EVAL_ERROR;
3914
3935
         $self->fail_session($session, 'remove_mysql_header() failed');
3915
 
         return;
 
3936
         return $self->{null_event};
3916
3937
      }
3917
3938
   }
3918
3939
 
3927
3948
            $self->_delete_buff($session);
3928
3949
         }
3929
3950
         else {
3930
 
            return;  # waiting for more data; buff_left was reported earlier
 
3951
            return $self->{null_event};  # waiting for more data; buff_left was reported earlier
3931
3952
         }
3932
3953
      }
3933
3954
      elsif ( $packet->{mysql_data_len} > ($packet->{data_len} - 4) ) {
3948
3969
 
3949
3970
         PTDEBUG && _d('Data not complete; expecting',
3950
3971
            $session->{buff_left}, 'more bytes');
3951
 
         return;
 
3972
         return $self->{null_event};
3952
3973
      }
3953
3974
 
3954
3975
      if ( $session->{cmd} && ($session->{state} || '') eq 'awaiting_reply' ) {
3971
3992
   }
3972
3993
 
3973
3994
   $args{stats}->{events_parsed}++ if $args{stats};
3974
 
   return $event;
 
3995
   return $event || $self->{null_event};
3975
3996
}
3976
3997
 
3977
3998
sub _packet_from_server {