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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aquariumtap’s picture

Status: Active » Needs review
FileSize
1.48 KB

I 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.

sheena_d’s picture

Status: Needs review » Needs work

Patch 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:

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`(40),`module`(40),`element`(40),`skin`(40)), KEY `theme` (`theme`), KEY `module` (`theme`,`module`), KEY `element` (`theme`,`module`,`element`), KEY `skin` (`skin`) ) ENGINE=In[...]

MySQL said: Documentation
#1071 - Specified key was too long; max key length is 1000 bytes 

The CREATE TABLE for fusion_apply_skins of my database dump (from localhost site after the patch) was:

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`(40),`module`(40),`element`(40),`skin`(40)),   
  KEY `theme` (`theme`),   
  KEY `module` (`theme`,`module`),   
  KEY `element` (`theme`,`module`,`element`),   
  KEY `skin` (`skin`) ) 
ENGINE=InnoDB AUTO_INCREMENT=178 DEFAULT CHARSET=utf8 COMMENT='Stores Fusion Apply data.' AUTO_INCREMENT=178;

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?

aquariumtap’s picture

So next thing to test would be to reduce the key length of these? I'm not clear on that the "Specified key" is.

  KEY `theme` (`theme`),   
  KEY `module` (`theme`,`module`),   
  KEY `element` (`theme`,`module`,`element`),   
  KEY `skin` (`skin`) ) 
authentictech’s picture

Version: 7.x-2.0-alpha1 » 7.x-2.0-alpha2

Same problem experienced on 7.x-2.0-alpha2 version when installing for the first time. Has anyone installed this module without this problem?

sheena_d’s picture

@authentitech - can you let us know what mySQL version you are running?

Thanks!

aquariumtap’s picture

Status: Needs work » Needs review
FileSize
1.72 KB

@sheena_d and @authentitech, could you send me the results of this query?

show variables like '%char%';

Here is mine. My guess is I haven't experienced the same issues because character_set_database is set to latin1.

mysql> show variables like '%char%';
+--------------------------+--------------------------------------------+
| Variable_name            | Value                                      |
+--------------------------+--------------------------------------------+
| character_set_client     | utf8                                       |
| character_set_connection | utf8                                       |
| character_set_database   | latin1                                     |
| character_set_filesystem | binary                                     |
| character_set_results    | utf8                                       |
| character_set_server     | latin1                                     |
| character_set_system     | utf8                                       |
| character_sets_dir       | /Applications/MAMP/Library/share/charsets/ |
+--------------------------+--------------------------------------------+
8 rows in set (0.00 sec)

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 is varchar(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.

sheena_d’s picture

This is on my database that was experiencing the error messages (mySQL version 5.1.41)

mysql> show variables like '%char%' ;
+--------------------------+---------------------------------------------+
| Variable_name            | Value                                       |
+--------------------------+---------------------------------------------+
| character_set_client     | utf8                                        |
| character_set_connection | utf8                                        |
| character_set_database   | utf8                                        |
| character_set_filesystem | binary                                      |
| character_set_results    | utf8                                        |
| character_set_server     | utf8                                        |
| character_set_system     | utf8                                        |
| character_sets_dir       | /opt/mysql/5.1.41-gm2/share/mysql/charsets/ |
+--------------------------+---------------------------------------------+
8 rows in set (0.00 sec)
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   | MUL |         |                |
| skin    | varchar(255)     | NO   | MUL |         |                |
| options | longtext         | NO   |     | NULL    |                |
| status  | tinyint(4)       | NO   |     | 0       |                |
+---------+------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

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.

sheena_d’s picture

Status: Needs review » Reviewed & tested by the community

patched 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.

aquariumtap’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Thanks for testing, @sheena_d! Committed.

drupalninja99’s picture

Status: Closed (fixed) » Needs work

I 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?

sheena_d’s picture

Status: Needs work » Closed (fixed)

The 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.

dan.mantyla’s picture

I 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.

sheena_d’s picture

This fix is included in Fusion Accelerator 7.x-2.0-beta1

nithinkolekar’s picture

Shouldn'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.