Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As I was restoring a database backup, I kept running into the following mySQL error:
-- Table structure for table `fusion_apply_skins` -- CREATE TABLE `fusion_apply_skins` ( `sid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'The primary identifier for a skin configuration.', `theme` varchar(128) NOT NULL DEFAULT '' COMMENT 'The theme this configuration applies to.', `module` varchar(128) NOT NULL DEFAULT '' COMMENT 'The module this configuration applies to.', `element` varchar(128) NOT NULL DEFAULT '' COMMENT 'The element this configuration applies to.', `skin` varchar(255) NOT NULL DEFAULT '' COMMENT 'The skin that has been applied.', `options` longtext NOT NULL COMMENT 'A serialized array containing the skin options that have been applied.', `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean indicating whether or not this item is enabled.', PRIMARY KEY (`sid`), UNIQUE KEY `theme_module_element_skin` (`theme`,`module`,`element`,`skin`), K[...]
MySQL said: Documentation
#1071 - Specified key was too long; max key length is 1000 bytes
I manually edited the structure of the fusion_apply_skins table. I changed the structure of the table keys from this:
UNIQUE KEY `theme_module_element_skin` (`theme`,`module`,`element`,`skin`),
KEY `theme` (`theme`),
KEY `module` (`theme`,`module`),
KEY `element` (`theme`,`module`,`element`),
KEY `skin` (`skin`)
To this (adding limits to the number of characters allowed from each key component):
UNIQUE KEY `theme_module_element_skin` (`theme`(40),`module`(40),`element`(40),`skin`(40)),
KEY `theme` (`theme`),
KEY `element` (`element`),
KEY `skin` (`skin`),
KEY `module` (`theme`(10),`module`(10),`element`(60))
and the import was successful.
I came to this solution from this mySQL bug report: http://bugs.mysql.com/bug.php?id=6604
The issue occurred on a server running mySQL 5.1.41 and the database dump had been generated by a server running 5.1.44, so this may just be an issue between mySQL versions.
Comment | File | Size | Author |
---|---|---|---|
#6 | 1325542-reduce-keylength-6.patch | 1.72 KB | aquariumtap |
#1 | 1325542-keylength.patch | 1.48 KB | aquariumtap |
Comments
Comment #1
aquariumtap CreditAttribution: aquariumtap commentedI did a mysqldump and dropped/imported my database for two separate Drupal+Accelerator installations, but no luck reproducing the bug. I'm using MySQL 5.5.9.
Looks like you changed which tables make up each key, not just the characters allowed by each component. eg, before/after:
KEY `module` (`theme`,`module`),
KEY `module` (`theme`(10),`module`(10),`element`(60))
But I think the important change is this, which didn't get reordered:
UNIQUE KEY `theme_module_element_skin` (`theme`(40),`module`(40),`element`(40),`skin`(40)),
Here's a patch that reduces the
theme_module_element_skin
key (the one MySQL was choking on) using the same numbers you used. The schema is updated through the install file, so you should just have to run update.php to alter the table. So to test, you'd have to:1) Restore that DB backup before changing the table keys (still have it?)
2) Run update.php
3) mysqldump, then try to restore again.
Comment #2
sheena_d CreditAttribution: sheena_d commentedPatch worked OK on my localhost site (mySQL 5.1.44). Ran update.php with no issues. When that was completed all of my skin settings were gone, but clearing site cache restored them.
When I tried to import the database from my localhost site (mySQL 5.1.44) to my webserver (mySQL 5.1.41) I still receive the same error:
The CREATE TABLE for fusion_apply_skins of my database dump (from localhost site after the patch) was:
I also compared the Skin export code from my localhost site pre-patch and post-patch, and the export code was the same. So perhaps, if it does not already, the update script should edit all entries in the table to shorten the keys?
Comment #3
aquariumtap CreditAttribution: aquariumtap commentedSo next thing to test would be to reduce the key length of these? I'm not clear on that the "Specified key" is.
Comment #4
authentictech CreditAttribution: authentictech commentedSame problem experienced on 7.x-2.0-alpha2 version when installing for the first time. Has anyone installed this module without this problem?
Comment #5
sheena_d CreditAttribution: sheena_d commented@authentitech - can you let us know what mySQL version you are running?
Thanks!
Comment #6
aquariumtap CreditAttribution: aquariumtap commented@sheena_d and @authentitech, could you send me the results of this query?
Here is mine. My guess is I haven't experienced the same issues because
character_set_database
is set tolatin1
.Unique keys are being built using the columns `theme`, `module`, `element` and `skin`.
mysql> describe fusion_apply_skins;
+---------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+----------------+
| sid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| theme | varchar(128) | NO | MUL | | |
| module | varchar(128) | NO | | | |
| element | varchar(128) | NO | | | |
| skin | varchar(255) | NO | MUL | | |
| options | longtext | NO | | NULL | |
| status | tinyint(4) | NO | | 0 | |
+---------+------------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)
As you can see, they are all
varchar(128)
, except`skin`
which isvarchar(255)
. On the surface, none of these keys should be hitting the 1000 byte limit. Three varchar(128) columns + one varchar(255) would appear to take up 639 bytes (3 * 128 + 1 * 255), but in multibyte storage, each character takes up more than one byte. MySQL reserves 3 bytes per character for utf8 storage, which makes the maximum limit 333 characters for keys.In the previous changeset, I reduced the length for `theme` + `module` + `element` + `skin` to 160 bytes (too aggressive, in retrospect). I should have also reduced `theme` + `module` + `element`. This patch will modify those keys and indexes. Please run update.php after applying the patch.
Comment #7
sheena_d CreditAttribution: sheena_d commentedThis is on my database that was experiencing the error messages (mySQL version 5.1.41)
So, yeah, it looks like the character encoding is what was causing you to not see the problem. I will test this patch #6 and respond shortly.
Comment #8
sheena_d CreditAttribution: sheena_d commentedpatched my localhost site and ran update.php (mySQL 5.1.44). Then, did a db dump and imported onto my server (mySQL 5.1.41) with no problems. After clearing cache all my Skins re-appeared as expected.
Comment #9
aquariumtap CreditAttribution: aquariumtap commentedThanks for testing, @sheena_d! Committed.
Comment #10
drupalninja99 CreditAttribution: drupalninja99 commentedI still get this error when installing Openchurch D7 with innodb enabled. I suppose maybe some innodb setting could be throttled but it seems like meaning environments, such as webenabled can't install the fusion tables. I tried out the dev version and it appears to work, could we get whatever patch fixes this out to a new stable tag?
Comment #11
sheena_d CreditAttribution: sheena_d commentedThe next stable release of Fusion Accelerator is awaiting thorough testing of our responsive features. If you would like to help move along the process of rolling a new stable release, we would love to have your feedback on the responsive features. Until we are ready to release those features, however, this issue will have to be resolved via the patch in this thread or by using the latest dev release.
Comment #12
dan.mantyla CreditAttribution: dan.mantyla commentedI could not even install Fusion Accelerator because of this problem. After unpacking into sites/all/modules and trying to enable Fusion Apply, I received the same error message as the original poster. However, the module was listed as installed. I then enabled the other Fusion modules, which caused killed the whole website and was non-recoverable. Here's how I fixed it.
I replaced line 71 of fusion_accelerator/fusion_apply/fusion_apply.install from this:
'element' => array('theme', 'module', 'element'),
to this:
'element' => array(array('theme', 10), array('module', 10), array('element',10)),
And it worked! I hope this can help somebody. Oh, and I'm using MySQL version 5.1.49 with PHP 5.2.14 on CentOS 5.5 (2.6.18-194.11.3.el5) and served via lighttpd 1.4.28 in a CHROOT jail.
Comment #13
sheena_d CreditAttribution: sheena_d commentedThis fix is included in Fusion Accelerator 7.x-2.0-beta1
Comment #14
nithinkolekar CreditAttribution: nithinkolekar commentedShouldn't be line 66 in fusion_apply.install (7.x-2.0-beta1+0-dev)
'theme_module_element_skin' => array('theme','module','element','skin')
instead of
'theme_module_element_skin' => array(array('theme', 40), array('module', 40), array('element', 40), array('skin', 40)),
Updating above line solved the same problem.