diff --git a/bin/pt-deadlock-logger b/bin/pt-deadlock-logger index ba08d00d..41572c2e 100755 --- a/bin/pt-deadlock-logger +++ b/bin/pt-deadlock-logger @@ -4616,43 +4616,44 @@ sub main { } } else { - if ( $ins_sth ) { - eval { - PTDEBUG && _d('Saving deadlock to --dest'); - foreach my $txn ( - sort { $a->{thread} <=> $b->{thread} } values %txns - ) { - $ins_sth->execute(@{$txn}{@cols}); - } - $dst->dbh->commit(); - }; - if ( my $e = $EVAL_ERROR ) { - PTDEBUG && _d('Error saving to --dest:', $e); - if ( $dst->lost_connection($e) ) { - eval { - $ins_sth->finish() if $ins_sth; - $dst->dbh->disconnect() if $dst->dbh; - $dst->connect(AutoCommit => 0); - $ins_sth = $dst->dbh->prepare($ins_sql); - }; - if ( $EVAL_ERROR ) { - warn "Lost connection to " . $dst->name . ". Will try " - . "to reconnect in the next iteration.\n"; - } - else { - PTDEBUG && _d('Reconnected to MySQL (--dest)'); - redo ITERATION; - } - } - else { - warn "Error saving to --dest: $EVAL_ERROR"; - $exit_status |= 1; - } - } - } - if ( $fingerprint ne $last_fingerprint ) { PTDEBUG && _d('New deadlock'); + + if ( $ins_sth ) { + eval { + PTDEBUG && _d('Saving deadlock to --dest'); + foreach my $txn ( + sort { $a->{thread} <=> $b->{thread} } values %txns + ) { + $ins_sth->execute(@{$txn}{@cols}); + } + $dst->dbh->commit(); + }; + if ( my $e = $EVAL_ERROR ) { + PTDEBUG && _d('Error saving to --dest:', $e); + if ( $dst->lost_connection($e) ) { + eval { + $ins_sth->finish() if $ins_sth; + $dst->dbh->disconnect() if $dst->dbh; + $dst->connect(AutoCommit => 0); + $ins_sth = $dst->dbh->prepare($ins_sql); + }; + if ( $EVAL_ERROR ) { + warn "Lost connection to " . $dst->name . ". Will try " + . "to reconnect in the next iteration.\n"; + } + else { + PTDEBUG && _d('Reconnected to MySQL (--dest)'); + redo ITERATION; + } + } + else { + warn "Error saving to --dest: $EVAL_ERROR"; + $exit_status |= 1; + } + } + } + if ( !$o->get('quiet') ) { print join($sep, @cols), "\n"; foreach my $txn (