LP #1043924: pt-deadlock-logger should store query checksums

Description

**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:

+# ###########################################################################

  1. This is a combination of modules and programs in one – a runnable module.

  2. http://www.perl.com/pub/a/2006/07/13/lightning-articles.html?page=last

  3. 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);

  1. A thread's proc_info can be at least 98 different things I've found in the

  2. 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

Environment

None

Smart Checklist

Activity

lpjirasync January 24, 2018 at 6:54 PM

**Comment from Launchpad by: Daniel Nichter on: 11-10-2012 21:35:48

It's a feature so I created https://blueprints.launchpad.net/percona-toolkit/+spec/pt-deadlock-logger-checksums

lpjirasync January 24, 2018 at 6:54 PM

**Comment from Launchpad by: Daniel Nichter on: 02-10-2012 21:54:59

Is this a bug or feature?

Not a Bug

Details

Assignee

Reporter

Priority

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