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
1=== modified file 'bin/pt-deadlock-logger'
2--- bin/pt-deadlock-logger 2014-06-05 07:24:48 +0000
3+++ bin/pt-deadlock-logger 2014-07-03 14:15:20 +0000
4@@ -4616,43 +4616,44 @@
5 }
6 }
7 else {
8- if ( $ins_sth ) {
9- eval {
10- PTDEBUG && _d('Saving deadlock to --dest');
11- foreach my $txn (
12- sort { $a->{thread} <=> $b->{thread} } values %txns
13- ) {
14- $ins_sth->execute(@{$txn}{@cols});
15- }
16- $dst->dbh->commit();
17- };
18- if ( my $e = $EVAL_ERROR ) {
19- PTDEBUG && _d('Error saving to --dest:', $e);
20- if ( $dst->lost_connection($e) ) {
21- eval {
22- $ins_sth->finish() if $ins_sth;
23- $dst->dbh->disconnect() if $dst->dbh;
24- $dst->connect(AutoCommit => 0);
25- $ins_sth = $dst->dbh->prepare($ins_sql);
26- };
27- if ( $EVAL_ERROR ) {
28- warn "Lost connection to " . $dst->name . ". Will try "
29- . "to reconnect in the next iteration.\n";
30- }
31- else {
32- PTDEBUG && _d('Reconnected to MySQL (--dest)');
33- redo ITERATION;
34- }
35- }
36- else {
37- warn "Error saving to --dest: $EVAL_ERROR";
38- $exit_status |= 1;
39- }
40- }
41- }
42-
43 if ( $fingerprint ne $last_fingerprint ) {
44 PTDEBUG && _d('New deadlock');
45+
46+ if ( $ins_sth ) {
47+ eval {
48+ PTDEBUG && _d('Saving deadlock to --dest');
49+ foreach my $txn (
50+ sort { $a->{thread} <=> $b->{thread} } values %txns
51+ ) {
52+ $ins_sth->execute(@{$txn}{@cols});
53+ }
54+ $dst->dbh->commit();
55+ };
56+ if ( my $e = $EVAL_ERROR ) {
57+ PTDEBUG && _d('Error saving to --dest:', $e);
58+ if ( $dst->lost_connection($e) ) {
59+ eval {
60+ $ins_sth->finish() if $ins_sth;
61+ $dst->dbh->disconnect() if $dst->dbh;
62+ $dst->connect(AutoCommit => 0);
63+ $ins_sth = $dst->dbh->prepare($ins_sql);
64+ };
65+ if ( $EVAL_ERROR ) {
66+ warn "Lost connection to " . $dst->name . ". Will try "
67+ . "to reconnect in the next iteration.\n";
68+ }
69+ else {
70+ PTDEBUG && _d('Reconnected to MySQL (--dest)');
71+ redo ITERATION;
72+ }
73+ }
74+ else {
75+ warn "Error saving to --dest: $EVAL_ERROR";
76+ $exit_status |= 1;
77+ }
78+ }
79+ }
80+
81 if ( !$o->get('quiet') ) {
82 print join($sep, @cols), "\n";
83 foreach my $txn (

Subscribers

People subscribed via source and target branches

to all changes: