pt-upgrade fails if select column > 64 chars

Bug #1060774 reported by Chris Howells
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
Daniel Nichter

Bug Description

My slow query log (generated from the real log by pt-query-digest contains the following query):

use XXX;
SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60;

(I've obscured the DB name)

This unfortunately causes pt-upgrade to break:

# pt_upgrade:10801 5341 DBD::mysql::db do failed: Identifier name '(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60' is too long at /usr/bin/pt-upgrade line 9070, <$fh> line 23515.
#
Newline in left-justified string for sprintf at /usr/bin/pt-upgrade line 8293, <$fh> line 23515.

[root@toolkit]# pt-upgrade --version
pt-upgrade 2.1.3
[root@toolkit]# cat /etc/issue
CentOS release 5.7 (Final)
Kernel \r on an \m

Related branches

Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Have (or can you) try 2.1.4? If I recall correctly, 2.1.4 has fixes to prevent these kind of printing errors from crashing the tool (the latter one I'm pretty sure of; the former "too long" error maybe not).

tags: added: crash pt-online-schema-change
Changed in percona-toolkit:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Daniel Nichter (daniel-nichter)
milestone: none → 2.1.5
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Which versions of MySQL are you using? I'm getting a similar error with two 5.1 instances:

Failed to execute query: DBD::mysql::db do failed: Incorrect column name '(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60' [for Statement "CREATE TEMPORARY TABLE `foo`.`mk_upgrade` AS SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60"] at /Users/daniel/Downloads/percona-toolkit-2.1.3/bin/pt-upgrade line 8766, <$fh> line 1.

Your error and that one probably have the same root cause: the tool is trying to create a temp table with a bad column (ident) name because it doesn't know that that expression isn't an ident and it's not escaping it. Parsing the SQL would help, but that's slow, so I'll have to think more about how to handle such cases.

Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

This might help, in lieu of parsing:

mysql> EXPLAIN SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: NULL
         type: NULL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: NULL
        Extra: No tables used

If a SELECT doesn't use tables then there's obviously no FROM clause, so whatever follows SELECT must be expressions.

Changed in percona-toolkit:
status: Triaged → In Progress
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

I can recreate the column name (identifier) problem, will fix. The newline problem should be fixed in 2.1.4+.

Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Chris, this should be fixed. Can you try by downloading pt-upgrade from trunk: http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/view/head:/bin/pt-upgrade Thanks.

summary: - pt-upgrade fails on a select query
+ pt-upgrade fails if select column > 64 chars
Changed in percona-toolkit:
status: In Progress → Fix Committed
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-587

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.