mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-02-28 02:07:54 +08:00
pqs: Removed tcpdump-errors, made the library always save the errors in a tempfile
This commit is contained in:
@@ -51,19 +51,7 @@ $Data::Dumper::Indent = 1;
|
||||
$Data::Dumper::Sortkeys = 1;
|
||||
$Data::Dumper::Quotekeys = 0;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our %EXPORT_TAGS = ();
|
||||
our @EXPORT = ();
|
||||
our @EXPORT_OK = qw(
|
||||
parse_error_packet
|
||||
parse_ok_packet
|
||||
parse_ok_prepared_statement_packet
|
||||
parse_server_handshake_packet
|
||||
parse_client_handshake_packet
|
||||
parse_com_packet
|
||||
parse_flags
|
||||
);
|
||||
use base 'ProtocolParser';
|
||||
|
||||
use constant {
|
||||
COM_SLEEP => '00',
|
||||
@@ -1526,46 +1514,6 @@ sub remove_mysql_header {
|
||||
return;
|
||||
}
|
||||
|
||||
sub _get_errors_fh {
|
||||
my ( $self ) = @_;
|
||||
my $errors_fh = $self->{errors_fh};
|
||||
return $errors_fh if $errors_fh;
|
||||
|
||||
# Errors file isn't open yet; try to open it.
|
||||
my $o = $self->{o};
|
||||
if ( $o && $o->has('tcpdump-errors') && $o->got('tcpdump-errors') ) {
|
||||
my $errors_file = $o->get('tcpdump-errors');
|
||||
PTDEBUG && _d('tcpdump-errors file:', $errors_file);
|
||||
open $errors_fh, '>>', $errors_file
|
||||
or die "Cannot open tcpdump-errors file $errors_file: $OS_ERROR";
|
||||
}
|
||||
|
||||
$self->{errors_fh} = $errors_fh;
|
||||
return $errors_fh;
|
||||
}
|
||||
|
||||
sub fail_session {
|
||||
my ( $self, $session, $reason ) = @_;
|
||||
PTDEBUG && _d('Client', $session->{client}, 'failed because', $reason);
|
||||
my $errors_fh = $self->_get_errors_fh();
|
||||
if ( $errors_fh ) {
|
||||
my $raw_packets = $session->{raw_packets};
|
||||
delete $session->{raw_packets}; # Don't dump, it's printed below.
|
||||
$session->{reason_for_failure} = $reason;
|
||||
my $session_dump = '# ' . Dumper($session);
|
||||
chomp $session_dump;
|
||||
$session_dump =~ s/\n/\n# /g;
|
||||
print $errors_fh "$session_dump\n";
|
||||
{
|
||||
local $LIST_SEPARATOR = "\n";
|
||||
print $errors_fh "@$raw_packets";
|
||||
print $errors_fh "\n";
|
||||
}
|
||||
}
|
||||
delete $self->{sessions}->{$session->{client}};
|
||||
return;
|
||||
}
|
||||
|
||||
# Delete anything we added to the session related to
|
||||
# buffering a large query received in multiple packets.
|
||||
sub _delete_buff {
|
||||
|
||||
Reference in New Issue
Block a user