pt-duplicate-key-checker fails when it encounters a crashed table

Bug #1047335 reported by Jay Janssen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Brian Fraser

Bug Description

$ PTDEBUG=1 pt-duplicate-key-checker
# /usr/bin/perl 5.008008
# Linux xxxx.xxxx.com 2.6.18-308.8.2.el5 #1 SMP Tue Jun 12 09:58:12 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
# Arguments:
# OptionParser:1123 14204 Option rule: This tool accepts additional command-line arguments. Refer to the SYNOPSIS and usage information for details.
# OptionParser:1132 14204 =item --all-structs
# OptionParser:1151 14204 Option has no attributes
# OptionParser:1159 14204 Short help: Compare indexes with different structs (BTREE, HASH, etc)
# OptionParser:1132 14204 =item --ask-pass
# OptionParser:1151 14204 Option has no attributes
# OptionParser:1159 14204 Short help: Prompt for a password when connecting to MySQL
# OptionParser:1132 14204 =item --charset
# OptionParser:1159 14204 Short help: Default character set
# OptionParser:1132 14204 =item --[no]clustered
# OptionParser:1159 14204 Short help: PK columns appended to secondary key is duplicate
# OptionParser:1132 14204 =item --config
# OptionParser:1159 14204 Short help: Read this comma-separated list of config files; if specified, this must be the first option on the command line
# OptionParser:1132 14204 =item --databases
# OptionParser:1159 14204 Short help: Check only this comma-separated list of databases
# OptionParser:1132 14204 =item --defaults-file
# OptionParser:1159 14204 Short help: Only read mysql options from the given file
# OptionParser:1132 14204 =item --engines
# OptionParser:1159 14204 Short help: Check only tables whose storage engine is in this comma-separated list
# OptionParser:1132 14204 =item --help
# OptionParser:1151 14204 Option has no attributes
# OptionParser:1159 14204 Short help: Show help and exit
# OptionParser:1132 14204 =item --host
# OptionParser:1159 14204 Short help: Connect to host
# OptionParser:1132 14204 =item --ignore-databases
# OptionParser:1159 14204 Short help: Ignore this comma-separated list of databases
# OptionParser:1132 14204 =item --ignore-engines
# OptionParser:1159 14204 Short help: Ignore this comma-separated list of storage engines
# OptionParser:1132 14204 =item --ignore-order
# OptionParser:1151 14204 Option has no attributes
# OptionParser:1159 14204 Short help: Ignore index order so KEY(a,b) duplicates KEY(b,a)
# OptionParser:1132 14204 =item --ignore-tables
# OptionParser:1159 14204 Short help: Ignore this comma-separated list of tables
# OptionParser:1132 14204 =item --key-types
# OptionParser:1159 14204 Short help: Check for duplicate f=foreign keys, k=keys or fk=both
# OptionParser:1132 14204 =item --password
# OptionParser:1159 14204 Short help: Password to use when connecting
# OptionParser:1132 14204 =item --pid
# OptionParser:1159 14204 Short help: Create the given PID file
# OptionParser:1132 14204 =item --port
# OptionParser:1159 14204 Short help: Port number to use for connection
# OptionParser:1132 14204 =item --set-vars
# OptionParser:1159 14204 Short help: Set these MySQL variables
# OptionParser:1132 14204 =item --socket
# OptionParser:1159 14204 Short help: Socket file to use for connection
# OptionParser:1132 14204 =item --[no]sql
# OptionParser:1159 14204 Short help: Print DROP KEY statement for each duplicate key
# OptionParser:1132 14204 =item --[no]summary
# OptionParser:1159 14204 Short help: Print summary of indexes at end of output
# OptionParser:1132 14204 =item --tables
# OptionParser:1159 14204 Short help: Check only this comma-separated list of tables
# OptionParser:1132 14204 =item --user
# OptionParser:1159 14204 Short help: User for login if not current user
# OptionParser:1132 14204 =item --verbose
# OptionParser:1159 14204 Short help: Output all keys and/or foreign keys found, not just redundant ones
# OptionParser:1132 14204 =item --version
# OptionParser:1151 14204 Option has no attributes
# OptionParser:1159 14204 Short help: Show version and exit
# OptionParser:1198 14204 Parsing opt spec: group => default spec => all-structs desc => Compare indexes with different structs (BTREE, HASH, etc)
# OptionParser:1236 14204 all-structs type: undef
# OptionParser:1198 14204 Parsing opt spec: group => default spec => ask-pass desc => Prompt for a password when connecting to MySQL
# OptionParser:1236 14204 ask-pass type: undef
# OptionParser:1198 14204 Parsing opt spec: group => default spec => charset|A=s desc => Default character set
# OptionParser:1236 14204 charset type: s
# OptionParser:1198 14204 Parsing opt spec: group => default spec => clustered! desc => PK columns appended to secondary key is duplicate (default yes)
# OptionParser:1236 14204 clustered type: undef
# OptionParser:1243 14204 clustered default: yes
# OptionParser:1198 14204 Parsing opt spec: group => default spec => config=A desc => Read this comma-separated list of config files; if specified, this must be the first option on the command line
# OptionParser:1236 14204 config type: A
# OptionParser:1198 14204 Parsing opt spec: group => default spec => databases|d=h desc => Check only this comma-separated list of databases
# OptionParser:1236 14204 databases type: h
# OptionParser:1198 14204 Parsing opt spec: group => default spec => defaults-file|F=s desc => Only read mysql options from the given file
# OptionParser:1236 14204 defaults-file type: s
# OptionParser:1198 14204 Parsing opt spec: group => default spec => engines|e=h desc => Check only tables whose storage engine is in this comma-separated list
# OptionParser:1236 14204 engines type: h
# OptionParser:1198 14204 Parsing opt spec: group => default spec => help desc => Show help and exit
# OptionParser:1236 14204 help type: undef
# OptionParser:1198 14204 Parsing opt spec: group => default spec => host|h=s desc => Connect to host
# OptionParser:1236 14204 host type: s
# OptionParser:1198 14204 Parsing opt spec: group => default spec => ignore-databases=H desc => Ignore this comma-separated list of databases
# OptionParser:1236 14204 ignore-databases type: H
# OptionParser:1198 14204 Parsing opt spec: group => default spec => ignore-engines=H desc => Ignore this comma-separated list of storage engines
# OptionParser:1236 14204 ignore-engines type: H
# OptionParser:1198 14204 Parsing opt spec: group => default spec => ignore-order desc => Ignore index order so KEY(a,b) duplicates KEY(b,a)
# OptionParser:1236 14204 ignore-order type: undef
# OptionParser:1198 14204 Parsing opt spec: group => default spec => ignore-tables=H desc => Ignore this comma-separated list of tables
# OptionParser:1236 14204 ignore-tables type: H
# OptionParser:1198 14204 Parsing opt spec: group => default spec => key-types=s desc => Check for duplicate f=foreign keys, k=keys or fk=both (default fk)
# OptionParser:1236 14204 key-types type: s
# OptionParser:1243 14204 key-types default: fk
# OptionParser:1198 14204 Parsing opt spec: group => default spec => password|p=s desc => Password to use when connecting
# OptionParser:1236 14204 password type: s
# OptionParser:1198 14204 Parsing opt spec: group => default spec => pid=s desc => Create the given PID file
# OptionParser:1236 14204 pid type: s
# OptionParser:1198 14204 Parsing opt spec: group => default spec => port|P=i desc => Port number to use for connection
# OptionParser:1236 14204 port type: i
# OptionParser:1198 14204 Parsing opt spec: group => default spec => set-vars=s desc => Set these MySQL variables (default wait_timeout=10000)
# OptionParser:1236 14204 set-vars type: s
# OptionParser:1243 14204 set-vars default: wait_timeout=10000
# OptionParser:1198 14204 Parsing opt spec: group => default spec => socket|S=s desc => Socket file to use for connection
# OptionParser:1236 14204 socket type: s
# OptionParser:1198 14204 Parsing opt spec: group => default spec => sql! desc => Print DROP KEY statement for each duplicate key (default yes)
# OptionParser:1236 14204 sql type: undef
# OptionParser:1243 14204 sql default: yes
# OptionParser:1198 14204 Parsing opt spec: group => default spec => summary! desc => Print summary of indexes at end of output (default yes)
# OptionParser:1236 14204 summary type: undef
# OptionParser:1243 14204 summary default: yes
# OptionParser:1198 14204 Parsing opt spec: group => default spec => tables|t=h desc => Check only this comma-separated list of tables
# OptionParser:1236 14204 tables type: h
# OptionParser:1198 14204 Parsing opt spec: group => default spec => user|u=s desc => User for login if not current user
# OptionParser:1236 14204 user type: s
# OptionParser:1198 14204 Parsing opt spec: group => default spec => verbose|v desc => Output all keys and/or foreign keys found, not just redundant ones
# OptionParser:1236 14204 verbose type: undef
# OptionParser:1198 14204 Parsing opt spec: group => default spec => version desc => Show version and exit
# OptionParser:1236 14204 version type: undef
# OptionParser:1258 14204 Parsing rule: This tool accepts additional command-line arguments. Refer to the SYNOPSIS and usage information for details.
# OptionParser:1314 14204 Participants for This tool accepts additional command-line arguments. Refer to the SYNOPSIS and usage information for details. :
# OptionParser:1290 14204 Strict mode disabled by rule
# OptionParser:1042 14204 Parsing DSN OPTIONS
# OptionParser:1132 14204 =item * A
# OptionParser:1159 14204 Short help: Default character set
# OptionParser:1132 14204 =item * D
# OptionParser:1159 14204 Short help: Default database
# OptionParser:1132 14204 =item * F
# OptionParser:1159 14204 Short help: Only read default options from the given file
# OptionParser:1132 14204 =item * h
# OptionParser:1159 14204 Short help: Connect to host
# OptionParser:1132 14204 =item * p
# OptionParser:1159 14204 Short help: Password to use when connecting
# OptionParser:1132 14204 =item * P
# OptionParser:1159 14204 Short help: Port number to use for connection
# OptionParser:1132 14204 =item * S
# OptionParser:1159 14204 Short help: Socket file to use for connection
# OptionParser:1132 14204 =item * u
# OptionParser:1159 14204 Short help: User for login if not current user
# DSNParser:612 14204 DSN option: copy=1, dsn=charset, desc=Default character set, key=A
# DSNParser:612 14204 DSN option: copy=1, dsn=database, desc=Default database, key=D
# DSNParser:612 14204 DSN option: copy=1, dsn=mysql_read_default_file, desc=Only read default options from the given file, key=F
# DSNParser:612 14204 DSN option: copy=1, dsn=host, desc=Connect to host, key=h
# DSNParser:612 14204 DSN option: copy=1, dsn=password, desc=Password to use when connecting, key=p
# DSNParser:612 14204 DSN option: copy=1, dsn=port, desc=Port number to use for connection, key=P
# DSNParser:612 14204 DSN option: copy=1, dsn=mysql_socket, desc=Socket file to use for connection, key=S
# DSNParser:612 14204 DSN option: copy=1, dsn=user, desc=User for login if not current user, key=u
# OptionParser:1086 14204 pt-duplicate-key-checker 2.1.3
# OptionParser:1398 14204 Cannot open /etc/percona-toolkit/percona-toolkit.conf: No such file or directory
#
# OptionParser:1398 14204 Cannot open /etc/percona-toolkit/pt-duplicate-key-checker.conf: No such file or directory
#
# OptionParser:1398 14204 Cannot open /home/percona/.percona-toolkit.conf: No such file or directory
#
# OptionParser:1398 14204 Cannot open /home/percona/.pt-duplicate-key-checker.conf: No such file or directory
#
# OptionParser:1586 14204 Nothing to validate for option key-types type s value fk
# OptionParser:1586 14204 Nothing to validate for option engines type h value undef
# OptionParser:1586 14204 Nothing to validate for option tables type h value undef
# OptionParser:1586 14204 Nothing to validate for option password type s value undef
# OptionParser:1586 14204 Nothing to validate for option pid type s value undef
# OptionParser:1586 14204 Nothing to validate for option user type s value undef
# OptionParser:1586 14204 Nothing to validate for option databases type h value undef
# OptionParser:1586 14204 Nothing to validate for option charset type s value undef
# OptionParser:1586 14204 Nothing to validate for option set-vars type s value wait_timeout=10000
# OptionParser:1586 14204 Nothing to validate for option port type i value undef
# OptionParser:1586 14204 Nothing to validate for option socket type s value undef
# OptionParser:1586 14204 Nothing to validate for option defaults-file type s value undef
# OptionParser:1586 14204 Nothing to validate for option host type s value undef
# DSNParser:628 14204 Setting set-vars property
# OptionParser:1660 14204 Getting description and usage from SYNOPSIS in /home/percona/bin/pt-duplicate-key-checker
# OptionParser:1913 14204 Parsing SYNOPSIS in /home/percona/bin/pt-duplicate-key-checker
# OptionParser:1926 14204 Raw SYNOPSIS text: Usage: pt-duplicate-key-checker [OPTION...] [DSN]
#
# pt-duplicate-key-checker examines MySQL tables for duplicate or redundant
# indexes and foreign keys. Connection options are read from MySQL option files.
#
#
# OptionParser:1664 14204 Description: pt-duplicate-key-checker examines MySQL tables for duplicate or redundant indexes and foreign keys. Connection options are read from MySQL option files.
# Usage: pt-duplicate-key-checker [OPTION...] [DSN]
# DSNParser:700 14204 DSN string made from options:
# DSNParser:637 14204 No DSN to parse
# DSNParser:752 14204 DBI:mysql:;;mysql_read_default_group=client
# DSNParser:798 14204 DBI:mysql:;;mysql_read_default_group=client undef undef mysql_enable_utf8=>0, ShowErrorStatement=>1, AutoCommit=>1, RaiseError=>1, PrintError=>0
# DSNParser:826 14204 DBI::db=HASH(0x121b6e30) SELECT @@SQL_MODE
# DSNParser:836 14204 DBI::db=HASH(0x121b6e30) SET @@SQL_QUOTE_SHOW_CREATE = 1/*!40101, @@SQL_MODE='NO_AUTO_VALUE_ON_ZERO'*/
# DSNParser:863 14204 DBI::db=HASH(0x121b6e30) : SET wait_timeout=10000
# DSNParser:871 14204 DBH info: DBI::db=HASH(0x121b6e30) $VAR1 = {
# '@@hostname' => 'xxxx.xxxxx.com',
# 'CONNECTION_ID()' => '866434',
# 'DATABASE()' => undef,
# 'VERSION()' => '5.1.60-community-log'
# };
# Connection info: Localhost via UNIX socket Character set info: $VAR1 = [
# {
# Value => 'latin1',
# Variable_name => 'character_set_client'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_connection'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_database'
# },
# {
# Value => 'binary',
# Variable_name => 'character_set_filesystem'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_results'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_server'
# },
# {
# Value => 'utf8',
# Variable_name => 'character_set_system'
# },
# {
# Value => '/usr/share/mysql/charsets/',
# Variable_name => 'character_sets_dir'
# }
# ];
# $DBD::mysql::VERSION: 3.0007 $DBI::VERSION: 1.52
# SchemaIterator:2987 14204 Schema object filters: $VAR1 = {};
#
# SchemaIterator:3093 14204 Getting next schema object from dbh DBI::db=HASH(0x121b6e30)
# SchemaIterator:3097 14204 SHOW DATABASES
# SchemaIterator:3159 14204 Database information_schema is a system database, ignoring
# SchemaIterator:3159 14204 Database #mysql50#lost+found is a system database, ignoring
# SchemaIterator:3100 14204 Found 9 databases
# SchemaIterator:3108 14204 Next database: backup
# SchemaIterator:3114 14204 SHOW /*!50002 FULL*/ TABLES FROM `backup`
# SchemaIterator:3125 14204 Found 1 tables in database backup
# TableParser:177 14204 /*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, @@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), @OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, @@SQL_QUOTE_SHOW_CREATE := 1 */
# TableParser:182 14204 DBI::db=HASH(0x121b6e30) USE `backup`
# TableParser:186 14204 SHOW CREATE TABLE `backup`.`tra_Documentation`
# TableParser:190 14204 DBD::mysql::db selectrow_hashref failed: Table './backup/tra_Documentation' is marked as crashed and last (automatic?) repair failed [for Statement "SHOW CREATE TABLE `backup`.`tra_Documentation`"] at /home/percona/bin/pt-duplicate-key-checker line 188.
#
# TableParser:192 14204 /*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, @@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */
# SchemaIterator:3244 14204 No engine specified; allowing the table
# SchemaIterator:3016 14204 Next schema object: backup tra_Documentation
Use of uninitialized value in pattern match (m//) at /home/percona/bin/pt-duplicate-key-checker line 408.

Related branches

Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: New → Confirmed
assignee: nobody → Brian Fraser (fraserbn)
importance: Undecided → Medium
Brian Fraser (fraserbn)
Changed in percona-toolkit:
milestone: none → 2.1.5
tags: added: crash pt-duplicate-key-checker
Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: Confirmed → In Progress
Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: In Progress → Fix Committed
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

TableParser::get_create_table now dies instead of returning nothing, so callers should do:

125 + my $ddl = eval { $tp->get_create_table($dbh, $self->{db}, $tbl) };
126 + if ( my $e = $EVAL_ERROR ) {
127 + my $table_name = "$self->{db}.$tbl";
128 + if ( $e =~ /\QTable '$table_name' doesn't exist/ ) {
129 + PTDEBUG && _d("Skipping $table_name because it no longer exists");
130 + }
131 + else {
132 + warn "Skipping $table_name because SHOW CREATE TABLE failed: $e";
133 + }
134 + next;
135 + }

Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: Fix Committed → Fix Released
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-578

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.