When running this on one of my sites/servers, I get the following error:
Converting table: block
Converting table: block_role
Converting table: block_custom
Converting table: cache_block
Cannot modify header information - headers already sent by (output [warning]
started at /usr/local/share/drush/includes/output.inc:38)
bootstrap.inc:1471
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes: ALTER TABLE {cache_block} MODIFY cid varchar(255) CHARACTER SET :charset COLLATE :collation; Array
(
[:charset] => utf8mb4
[:collation] => utf8mb4_general_ci
)
in DrupalCharsetConverter->convertTableFields() (line 174 of /home/geerlingguy/.drush/utf8mb4_convert/utf8mb4_convert.drush.inc).
Drush command terminated abnormally due to an unrecoverable error. [error]
Is there a way a check could be run to help the user figure out what the problem is / how to fix it? For most users, this is a bit cryptic.
See: http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-lo...
Comments
Comment #2
geerlingguy commentedIt looks like in my case, it was due to these two lines missing in the
[mysqld]config insidemy.cnf:(As mentioned in the general Drupal.org documentation page: https://www.drupal.org/node/2754539).
I had to add those two lines and restart MySQL, then everything worked fine. We should maybe document this on the project page itself, in case people skim through the Drupal.org docs or don't see them at all, and only see this PDOException.
Comment #3
geerlingguy commentedHmm... Note that on the same server, with a different database/site, I got a similar error, but for 1000 bytes, for the
filter_formattable:Comment #4
geerlingguy commentedAdding related issue #1852896: Throw an exception if a schema defines a key that would be over 1000 bytes in MySQL.
Comment #5
geerlingguy commentedA quick fix (which isn't by any means recommended... but will help you get through the table conversions):Manually change the VARCHAR column length in an affected table (with the 1000 byte limitation) to250instead of255.Apparently one of my databases was MyISAM—this was a really old database that started in Drupal 5, upgraded to 6, then 7, and was along the ride through many different servers/hosting companies! After I converted the tables from MyISAM to InnoDB, all was well in the world.
Comment #6
stefan.r commented#2 is odd. Don't you get a
The x:y MySQL database does not support UTF8MB4! Ensure that the conditions listed in settings.php related to innodb_large_prefix, the server version, and the MySQL driver version are met" warning when innodb_large_prefix is turned off?It does a $connection->utf8mb4IsSupported() check, which should try to create a table with a large prefix, and show the warning. I wonder if you either missed the warning, or if this code is incorrect?
In any case, besides showing the warning, it should also *not try to convert* of course (it did previously), so committing a fix for that now.
Comment #8
stefan.r commentedJust to add to this, we now convert all tables to InnoDB automatically.
Comment #9
geerlingguy commented+1, thanks!
Comment #10
stefan.r commented@geerlingguy just so I can evaluate whether to mark this as fixed, could you perhaps answer #6 by reverting to the old mysql settings/database and seeing if you can still reproduce the error in the OP in the latest version of the project? (Alpha4 I think)
Comment #11
geerlingguy commented@stefan.r - sure thing! I'll test in a little bit and post the results here.
Comment #12
geerlingguy commented@stefan.r - Everything works perfectly now; no errors whatsoever!
Also checked over your updates to the project page, and they're very helpful. I wrote up a quick blog post on it as well... hopefully it doesn't break drupal.org's Planet aggregator—is d.o upgraded to 7.50 yet?
Comment #13
stefan.r commented@geerlingguy, that doesn't sound right :)
We *want* an error to appear when innodb_large_prefix is turned off. Is that what happens now?
Thanks a lot for the blog post!
Comment #14
geerlingguy commented@stefan.r - Oops! Sorry about that, I had it turned on, was only testing the automatic InnoDB table conversion. I'll try to get the test setup again later.
Comment #15
ptmkenny commentedI'm getting a similar error on Pantheon:
A few notes:
$connection->utf8mb4IsSupported()check because if I leave the check in I get this warning:Despite this check, Pantheon's implementation of nginx does support utf8mb4. I know this because I previously used a different patch that ultimately was not committed to core to support emoji on my site. (Since upgrading to 7.50, I have undone this patch.)
Unfortunately although I use Drupal a lot my understanding of databases is limited so I'm not sure how to go about fixing this.
Comment #16
stefan.r commented@geerlingguy any feedback on #13?
@ptmkenny, obviously you can't just comment out the support check -- if it fails, then yes, the conversion is going to fail :)
The warning is a bit unclear yes, it's not really true that "MySQL database does not support UTF8MB4"... just rather that your Pantheon etup doesn't seem to comply with some of the listed requirements in order to have UTF8MB4 support in Drupal core (which are stricter than the ones in earlier patches). So I'd check with them.
Comment #17
ptmkenny commented@stefan.r Thanks for your input. I talked to Pantheon support, and they said that they do support uf8mb4. So I tried to dig into the matter deeper and this is what I found:
When it fails converting a table, the table that failed conversion will be the last one printed out, for example:
Converting table: cache_block
I can then look at that table and run a query on the first column like this:
ALTER TABLE cache_block CHANGE cid cid VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Then I can re-run the command and a different table will fail. For example, commerce_order also failed. In the case of commerce_order, there are several columns:
order_number
type
mail
status
hostname
All of which are VARCHAR with an encoding/collation set, but I only needed to run the ALTER TABLE query manually for order_number, and then utf8mb4_convert was able to keep processing.
I'm not sure how to fix this but please let me know if this is helpful.
Comment #18
ptmkenny commentedUpdate: I heard back from Pantheon support again and actually at this time their database configuration does not meet all of the new 7.50 requirements.
Comment #19
stephane bouillet commentedHi
as for me I had an old drupal install (4.7), evolved in drupal 7 now.
when doing the code
drush utf8mb4-convert-databasesit gives error:
After several try (nothing worked) to change the type of the table node_revision from MyINSAM to InnoDB, I finally compare the table node_revision with another site (younger) where the
drush utf8mb4-convert-databasesworked, and see the full text was in couple with the similar line.So I deleted the line with "similar" in red, and make again the
drush utf8mb4-convert-databasesthat finally worked.Not sure that it is a good solution...?
thanks for advices