Merge lp:~percona-toolkit-dev/percona-toolkit/pt-deadlock-logger-introduces-a-noise-to-mysql-1258135 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.9

Proposed by Frank Cizmich
Status: Merged
Merged at revision: 611
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-deadlock-logger-introduces-a-noise-to-mysql-1258135
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.9
Diff against target: 83 lines (+36/-35)
1 file modified
bin/pt-deadlock-logger (+36/-35)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-deadlock-logger-introduces-a-noise-to-mysql-1258135
Reviewer Review Type Date Requested Status
Percona Toolkit developers Pending
Review via email: mp+225483@code.launchpad.net

Description of the change

Avoids attempting unnecessary duplicate inserts in deadlock table.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-deadlock-logger'
--- bin/pt-deadlock-logger 2014-06-05 07:24:48 +0000
+++ bin/pt-deadlock-logger 2014-07-03 14:15:20 +0000
@@ -4616,43 +4616,44 @@
4616 }4616 }
4617 }4617 }
4618 else {4618 else {
4619 if ( $ins_sth ) {
4620 eval {
4621 PTDEBUG && _d('Saving deadlock to --dest');
4622 foreach my $txn (
4623 sort { $a->{thread} <=> $b->{thread} } values %txns
4624 ) {
4625 $ins_sth->execute(@{$txn}{@cols});
4626 }
4627 $dst->dbh->commit();
4628 };
4629 if ( my $e = $EVAL_ERROR ) {
4630 PTDEBUG && _d('Error saving to --dest:', $e);
4631 if ( $dst->lost_connection($e) ) {
4632 eval {
4633 $ins_sth->finish() if $ins_sth;
4634 $dst->dbh->disconnect() if $dst->dbh;
4635 $dst->connect(AutoCommit => 0);
4636 $ins_sth = $dst->dbh->prepare($ins_sql);
4637 };
4638 if ( $EVAL_ERROR ) {
4639 warn "Lost connection to " . $dst->name . ". Will try "
4640 . "to reconnect in the next iteration.\n";
4641 }
4642 else {
4643 PTDEBUG && _d('Reconnected to MySQL (--dest)');
4644 redo ITERATION;
4645 }
4646 }
4647 else {
4648 warn "Error saving to --dest: $EVAL_ERROR";
4649 $exit_status |= 1;
4650 }
4651 }
4652 }
4653
4654 if ( $fingerprint ne $last_fingerprint ) {4619 if ( $fingerprint ne $last_fingerprint ) {
4655 PTDEBUG && _d('New deadlock');4620 PTDEBUG && _d('New deadlock');
4621
4622 if ( $ins_sth ) {
4623 eval {
4624 PTDEBUG && _d('Saving deadlock to --dest');
4625 foreach my $txn (
4626 sort { $a->{thread} <=> $b->{thread} } values %txns
4627 ) {
4628 $ins_sth->execute(@{$txn}{@cols});
4629 }
4630 $dst->dbh->commit();
4631 };
4632 if ( my $e = $EVAL_ERROR ) {
4633 PTDEBUG && _d('Error saving to --dest:', $e);
4634 if ( $dst->lost_connection($e) ) {
4635 eval {
4636 $ins_sth->finish() if $ins_sth;
4637 $dst->dbh->disconnect() if $dst->dbh;
4638 $dst->connect(AutoCommit => 0);
4639 $ins_sth = $dst->dbh->prepare($ins_sql);
4640 };
4641 if ( $EVAL_ERROR ) {
4642 warn "Lost connection to " . $dst->name . ". Will try "
4643 . "to reconnect in the next iteration.\n";
4644 }
4645 else {
4646 PTDEBUG && _d('Reconnected to MySQL (--dest)');
4647 redo ITERATION;
4648 }
4649 }
4650 else {
4651 warn "Error saving to --dest: $EVAL_ERROR";
4652 $exit_status |= 1;
4653 }
4654 }
4655 }
4656
4656 if ( !$o->get('quiet') ) {4657 if ( !$o->get('quiet') ) {
4657 print join($sep, @cols), "\n";4658 print join($sep, @cols), "\n";
4658 foreach my $txn (4659 foreach my $txn (

Subscribers

People subscribed via source and target branches

to all changes: