Constraint name is too long

Bug #1491674 reported by Denis Malinovsky
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Carlos Salguero

Bug Description

pt-online-schema-change is adding an underscore to the new table constraint's name, and it's causing the problem when FK name length is already 64 characters long.

It's happening in the latest version 2.2.15.

Example output (made with `--dry-run` option):

Error creating new table: DBD::mysql::db do failed: Identifier name '_suresc_formulary_id_551efe76791cde00_fk_surescripts_formulary_id' is too long [for Statement "CREATE TABLE `chronometer_production`.`_surescripts_formularydrug_new` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `syn_id` int(11) DEFAULT NULL,
  `pkg_product_id` varchar(11) COLLATE utf8_unicode_ci NOT NULL,
  `status` int(11) NOT NULL,
  `relative_cost` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `formulary_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `surescripts_formularydrug_cfb5099b` (`syn_id`),
  KEY `surescripts_formularydrug_83b60bd0` (`pkg_product_id`),
  KEY `surescripts_formularydrug_618299a8` (`formulary_id`),
  CONSTRAINT `_suresc_formulary_id_551efe76791cde00_fk_surescripts_formulary_id` FOREIGN KEY (`formulary_id`) REFERENCES `surescripts_formulary` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=410072014 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPRESSED"] at /usr/bin/pt-online-schema-change line 9890.

I realize that the FK name is too long, but it's generated automatically by our software framework, so we don't have any control over it.

It might be a better idea to use UUIDs or something similar to generate new constraint names.

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

pt-table-checksum has always had this behavior. In this latest version it is improved because it alternates adding and subtracting
Using an UUID or similar would guarantee uniqueness and has been considered before.
The ugly part is that we'd have to arbitrarily truncate very long names.
This is really a very border case. A dynamically generated name that happens to be exactly the max length allowed!
But I appreciate it's affecting you.

A random id would be the ultimate solution to name conflict, at the cost of readability perhaps.

Revision history for this message
Nilnandan Joshi (nilnandan-joshi) wrote :

Set to confirmed as a feature request.

Changed in percona-toolkit:
status: New → Confirmed
Revision history for this message
Denis Malinovsky (dmalinovsky) wrote :

I've attached a naive one-liner fix of this problem for the latest version (2.2.17 at the moment).

Revision history for this message
Denis Malinovsky (dmalinovsky) wrote :
tags: added: pt144
Revision history for this message
Carlos Salguero (carlos-salguero) wrote :
Changed in percona-toolkit:
assignee: nobody → Carlos Salguero (carlos-salguero)
status: Confirmed → Fix Committed
importance: Undecided → Medium
milestone: none → 3.0.4
Changed in percona-toolkit:
status: Fix Committed → Fix Released
Revision history for this message
Denis Malinovsky (dmalinovsky) wrote : Re: [Bug 1491674] Re: Constraint name is too long

Thanks!
On Fri, Aug 4, 2017 at 14:54 Carlos Salguero <email address hidden>
wrote:

> ** Changed in: percona-toolkit
> Status: Fix Committed => Fix Released
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1491674
>
> Title:
> Constraint name is too long
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/percona-toolkit/+bug/1491674/+subscriptions
>

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-692

Revision history for this message
W. Koot (wkoot) wrote :

Is there a plan for backporting this to Ubuntu 12.04 LTS?
Current release for 12.04 is 3.0.3; only one patch below 3.0.4

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.