pt-online-schema-change --dry-run always fails on table with foreign keys

Bug #1003315 reported by Harm Verhagen
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Brian Fraser

Bug Description

pt-online-schema-change --dry-run always fails if a table has a foreign key.
Same command with --execute works.

steps to reproduce
===============
1. Create the following tables
use harm_test;

DROP TABLE IF EXISTS `B`;
DROP TABLE IF EXISTS `A`;
CREATE TABLE `A` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `foo` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

DROP TABLE IF EXISTS `B`;
CREATE TABLE `B` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `a` int(11) NOT NULL,
  KEY `9dde1f34` (`a`),
  PRIMARY KEY (`id`),
  CONSTRAINT `6970ddb42bec57fc` FOREIGN KEY (`a`) REFERENCES `A` (`id`)
) ENGINE=InnoDB;

INSERT INTO `A` VALUES (1,'bar'), (2,'bar2'), (3,'bar3');
INSERT INTO `B` VALUES (1, 1), (2, 2), (3, 1);

2. then run pt-online-schema-change
 pt-online-schema-change --alter "ENGINE=InnoDB" D=harm_test,t=A --user harm --password harm --alter-foreign-keys-method auto --dry-run || echo failed

expected result
============
1. No errors are shown
2. executable exits with a OK return value (0)

actual result
==========
1. you get this error message "Error updating foreign key constraints: Invalid --alter-foreign-keys-method: "
2. executable exits with an ERROR value ( || echo failed -> fires ) making it hard to use it in scripts

{{{
harm@dev3:$ pt-online-schema-change --alter "ENGINE=InnoDB" D=harm_test,t=A --user harm --password harm --alter-foreign-keys-method auto --lock-wait-time=50 --dry-run || echo failed
Child tables:
  `harm_test`.`B` (approx. 3 rows)
Will automatically choose the method to update foreign keys.
Starting a dry run. `harm_test`.`A` will not be altered. Specify --execute instead of --dry-run to alter the table.
Creating new table...
Created new table harm_test._A_new OK.
Altering new table...
Altered `harm_test`.`_A_new` OK.
Not creating triggers because this is a dry run.
Not copying rows because this is a dry run.
Not determining the method to update foreign keys because this is a dry run.
Not swapping tables because this is a dry run.
Error updating foreign key constraints: Invalid --alter-foreign-keys-method:

Not dropping triggers because this is a dry run.
Dropping new table...
Dropped new table OK.
Dry run complete. `harm_test`.`A` was not altered.
failed
}}}

version info
============
mysql 5.1.62-0ubuntu0.10.04.1
percona-toolkit-2.1.1

Related branches

Revision history for this message
Harm Verhagen (harm-verhagen) wrote :

perconatools -> percona-toolkit

affects: perconatools → percona-toolkit
description: updated
tags: added: crash pt-online-schema-change
summary: - online-schema-change dry-run always fails on table with foreignkeys
+ pt-online-schema-change --dry-run always fails on table with foreign
+ keys
Changed in percona-toolkit:
status: New → Triaged
milestone: none → 2.1.2
importance: Undecided → Medium
assignee: nobody → Brian Fraser (fraserbn)
Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: Triaged → Fix Committed
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-535

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.