pt-online-schema-change segfaulting on column named `key`

Bug #1499526 reported by Joshua Griffith
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Triaged
Undecided
Frank Cizmich

Bug Description

Altering a table containing a column named the reserved word `key` causes pt-online-schema-change to segfault. Enclosing the column name in back-ticks does not appear to have any effect:

CREATE TABLE some_data(`key` VARCHAR(100) NOT NULL);

# pt-online-schema-change --host mysql --socket '' --user '' --password '' --execute D=development,t=some_data --alter 'CHANGE key key1' --recursion-method dsn=D=development,t=dsns
No slaves found. See --recursion-method if host b70dd8590ec1 has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
  copy_rows, 10, 0.25
  create_triggers, 10, 1
  drop_triggers, 10, 1
  swap_tables, 10, 1
  update_foreign_keys, 10, 1
Altering `development`.`some_data`...
--alter appears to rename these columns:
  key to key1
The tool should handle this correctly, but you should test it first because if it fails the renamed columns' data will be lost! Specify --no-check-alter to disable this check and perform the --alter.
`development`.`some_data` was not altered.
Segmentation fault (core dumped)

Revision history for this message
Joshua Griffith (josmua) wrote :

Note: Using pt-online-schema-change version 2.2.11
Similar to: https://bugs.launchpad.net/percona-toolkit/+bug/873598

affects: percona-server → perconatools
affects: perconatools → percona-toolkit
tags: added: pt-online-schema-change
Changed in percona-toolkit:
status: New → Triaged
assignee: nobody → Frank Cizmich (frank-cizmich)
Revision history for this message
Frank Cizmich (frank-cizmich) wrote :

Hello Joshua,

Yup, it's an issue, thanks for reporting.

Here's a workaround for now:

Use *escaped* backticks around the problematic names, i.e: \`key\`

Also very important !!:
- the CHANGE directive requires that you specify the new column datatype. Example: CHANGE foo bar varchar(10)
- you will need to also use "--no-check-alter" option ( or the tool will nag you and refuse to run )
- please upgrade to version 2.2.15 ! since previous versions die when the ALTER statement is syntactically wrong and give no clue as to why.

Regards!

Revision history for this message
Joshua Griffith (josmua) wrote :

Thanks for the workaround. I was actually creating an index, but change provided a simpler example.

Revision history for this message
Frank Cizmich (frank-cizmich) wrote :

Thanks for the feedback.

On a second look at the issue, I think that simple (unescaped) backticks should do it. The escaped backticks are only necessary if you are enclosing the alter option in double quotes. (This is what threw me off).
The other stuff I mentioned still stands. Mainly: Upgrade to 2.2.15 to get proper error messages! :-)

Also: do a "--dry-run" before an actual "--excecute", to catch potential errors.

Revision history for this message
Joshua Griffith (josmua) wrote :

Odd, I tried both escaped and unescaped backticks and still got a segfault. Will upgrade to 2.2.15 today. Thanks for looking at this issue!

Revision history for this message
Frank Cizmich (frank-cizmich) wrote :

You're welcome,

BTW , I'm tagging this as a duplicate of:
https://bugs.launchpad.net/percona-toolkit/+bug/1446928
because I think that one contains the core of the issue reported here.
Feel free to comment if you disagree.

Cheers

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.