Not a Bug
Details
Assignee
UnassignedUnassignedReporter
lpjirasynclpjirasync(Deactivated)Priority
Low
Details
Details
Assignee
Unassigned
UnassignedReporter
lpjirasync
lpjirasync(Deactivated)Priority
Smart Checklist
Smart Checklist
Smart Checklist
Created January 24, 2018 at 6:53 PM
Updated February 4, 2018 at 12:37 AM
Resolved January 24, 2018 at 6:54 PM
**Reported in Launchpad by Baron Schwartz last update 11-10-2012 21:36:00
To help analyze information on which deadlocks are most frequent, pt-deadlock-logger should store a checksum of the query's fingerprint with the record it inserts. A quick and dirty hack in my local copy: add a couple of modules, then:
+# ###########################################################################
This is a combination of modules and programs in one – a runnable module.
http://www.perl.com/pub/a/2006/07/13/lightning-articles.html?page=last
Or, look it up in the Camel book on pages 642 and 643 in the 3rd edition.
@@ -2371,6 +3515,7 @@
use English qw(-no_match_vars);
use List::Util qw(max);
use Socket qw(inet_aton);
+Transformers->import(qw(make_checksum));
use sigtrap qw(handler finish untrapped normal-signals);
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
@@ -2392,6 +3537,8 @@
my $n = qr/(
+)/; # MySQL object name
my $w = qr/(\w+)/; # Words
my $s = qr/(\d{6} .\d:\d\d:\d\d)/; # InnoDB timestamp
+my $qp = new QueryParser();
+my $qr = new QueryRewriter(QueryParser=>$qp);
A thread's proc_info can be at least 98 different things I've found in the
source. Fortunately, most of them begin with a gerunded verb. These are
@@ -2489,7 +3636,7 @@
}
my @cols = qw( server ts thread txn_id txn_time user hostname ip db tbl idx
lock_type lock_mode wait_hold victim query );
+ lock_type lock_mode wait_hold victim query checksum );
if ( $o->got('columns') ) {
@cols = grep { $o->get('columns')->{$_} } @cols;
}
@@ -2551,6 +3698,7 @@
if ( $ins_sth ) {
foreach my $txn (sort { $a->{thread} <=> $b->{thread} } values %txns) {
die $text unless $txn->{db};
+ $txn->{checksum} = make_checksum($qr->fingerprint($txn->{query} || ''));
$ins_sth->execute(@{$txn}{@cols});
}
$dest_dbh->commit();
@@ -3108,6 +4256,7 @@
wait_hold char(1) NOT NULL,
victim tinyint unsigned NOT NULL,
query text NOT NULL,
+ checksum char(32) NOT NULL,
PRIMARY KEY (server,ts,thread)
) ENGINE=InnoDB