Update from 6.0.3 to oc7 alpha 2 - Specified key was too long; max key length is 1000 bytes
I can offer a database to debug, if needed.
Steps to reproduce
- Upgrade existing Installation to master
- Open browser
- Start upgrade
Expected behaviour
Successful upgrade
Actual behaviour
Error:
An exception occurred while executing 'CREATE INDEX oc_53a94eb71627d ON oc_oc_share_53a94eb707aec (file_target, uid_owner, share_type)': SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
Server configuration
Operating system:Ubuntu 12.04.4
Web server: Apache
Database: Mysql 5.5
PHP version: PHP 5.3.10-1ubuntu3.12
Logs
Web server error log
Insert your webserver log here
ownCloud log (data/owncloud.log)
{"reqId":"53a94eb5c4583","app":"core","message":"starting upgrade from 6.0.3.1 to 7.0.0.1","level":0,"time":"2014-06-24T10:11:01+00:00","method":"GET","url":"\/\/core\/ajax\/update.php?requesttoken=ef69244d30043bbf3f49"}
{"reqId":"53a94eb5c4583","app":"core","message":"Simulated database structure update failed (exception 'OC\\DB\\MigrationException' with message 'An exception occurred while executing 'CREATE INDEX oc_53a94eb71627d ON `oc_oc_share_53a94eb707aec` (`file_target`, `uid_owner`, `share_type`)':\n\nSQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes' in \/var\/www\/virtual\/xy.portknox.net\/htdocs\/lib\/private\/db\/migrator.php:115\nStack trace:\n#0 \/var\/www\/virtual\/xy.portknox.net\/htdocs\/lib\/private\/db\/migrator.php(75): OC\\DB\\Migrator->checkTableMigrate(Object(Doctrine\\DBAL\\Schema\\Table))\n#1 \/var\/www\/virtual\/xy.portknox.net\/htdocs\/lib\/private\/db\/mdb2schemamanager.php(112): OC\\DB\\Migrator->checkMigrate(Object(Doctrine\\DBAL\\Schema\\Schema))\n#2 \/var\/www\/virtual\/xy.portknox.net\/htdocs\/lib\/private\/db.php(327): OC\\DB\\MDB2SchemaManager->simulateUpdateDbFromStructure('\/var\/www\/virtua...')\n#3 \/var\/www\/virtual\/xy.portknox.net\/htdocs\/lib\/private\/updater.php(186): OC_DB::simulateUpdateDbFromStructure('\/var\/www\/virtua...')\n#4 \/var\/www\/virtual\/xy.portknox.net\/htdocs\/lib\/private\/updater.php(137): OC\\Updater->doUpgrade('7.0.0.1', '6.0.3.1')\n#5 \/var\/www\/virtual\/xy.portknox.net\/htdocs\/core\/ajax\/update.php(35): OC\\Updater->upgrade()\n#6 {main})","level":4,"time":"2014-06-24T10:11:03+00:00","method":"GET","url":"\/\/core\/ajax\/update.php?requesttoken=ef69244d30043bbf3f49"}
Debugged it a bit, but not sure what needs to be done:
The oc_share table was has storage engine MyISAM, i changed it to InnoDB.
Upgrade was successful after this change.
strange bug. @DeepDiver1975 @bantu Do you know why old ownCloud installations might use myisam and new one innodb?
If i remember correctly this ownCloud installation was upgraded from oc5 to oc6.
@karlitschek The default storage engine has changed from MyISAM to InnoDB at some point (apparently MySQL 5.5.5). So, unless we explicitly specify a storage engine (I think we don't, since this is also supposed to work on a cluster), this explains it.
@bantu Got it. So this depends on the MySQL version that was used at the time ownCloud was first installed. This is even more tricky. :-(
So the only possible fix is to remove our shiny new index again, right?
@karlitschek InnoDB has been around for quite a while, so you could also just tell people to switch to a different storage engine or even do that for them.
@bantu sure. But we need to to this automatically during upgrade somehow. Can you help with that?
@karlitschek uid_owner can be reduced from varchar(255) to varchar(100) since the users table can not hold anything bigger than that anyway.
Awesome. Very good idea!!
@karlitschek like @bantu mentioned on possible solution is to switch the engine. So this sql command fix this bug on MySQL 5.5.31
ALTER TABLE `oc_share` ENGINE = InnoDB;
agreed. Can one of you open a pull request for that?
In my case all the tables are InnoDB, but I still get this error. I changed uid_owner to varchar(100) and even to varchar(25), but still...
Anything else to try?
Got past this error when I ALSO switched the table's character set to latin1.
BTW, using OpenSUSE 13.1 and MySQL 5.6.12.
@gomez Can you retest this with current master. And reopen the issue if it still exists? Thanks
Retested. Still does not work.
Does the db_structure.xml get executed before the upgrade? The table length wasn't changed after the upgrade try. Or is this a roleback?
I manually changed the uid_owner table to varchar(64) and fired the upgrade, still no success with the same error.
Did you try switching to latin1? I think I tried it myself basing on MySQL bug http://bugs.mysql.com/bug.php?id=68453.
cc @butonic
@Gomez Do you get the exact same error? You try to migrate from 6.x to master, right?
Hi,
similar problem during upgrade from 5.0.16 (which runs on ubuntu 10.04, PHP Version 5.3.2-1ubuntu4.25, mysql version 5.1.73-0ubuntu0.10.04.1) to 7.0.0beta1 (running on ubuntu 12.04, PHP Version 5.3.10-1ubuntu3.12, mysql version 5.5.37-0ubuntu0.12.04.1). The exact error message is:
An exception occurred while executing 'CREATE INDEX oc_53b1c544d2678 ON oc_oc_share_53b1c544d1d76 (file_target, uid_owner, share_type)': SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
I'm not very familiar with those mysql-details you mentionend. Let me know, in case I can help by looking for more details.