Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.4.10, 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11
-
None
-
Linux
Description
after upgrading to 1.4 from 10.3, I execute mysql_upgrade and I get
mysql.user OK
Phase 4/7: Running 'mysql_fix_privilege_tables'
ERROR 1071 (42000) at line 437: Specified key was too long; max key length is 1000 bytes
FATAL ERROR: Upgrade failed
But, that is mariadb upgrader code that fails, for my server does not have a single innodb table, all are Rocksdb. If I start Mariadb with skip-innodb=1, there is no error, therefore, the error happens with the upgrader tries to create performance tables for inndb.
if this is a table from mysql then a descriptive message should say what table is the offending one. I tried to trace all activity and the last message is:
36 Prepare DROP DATABASE IF EXISTS performance_schema
36 Query EXECUTE stmt
36 Execute DROP DATABASE IF EXISTS performance_schema
36 Query DROP PREPARE stmt
36 Query SET @cmd= "CREATE DATABASE performance_schema character set utf8"
36 Query SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0')
36 Query PREPARE stmt FROM @str
36 Prepare CREATE DATABASE performance_schema character set utf8
36 Query EXECUTE stmt
36 Execute CREATE DATABASE performance_schema character set utf8
36 Query DROP PREPARE stmt
36 Quit
so what comes next is generating the error. How do we know what code is being applied?
Attachments
Issue Links
- is duplicated by
-
MDEV-31148 myqsl_upgrade fails: mysql.innodb_index_stats not present
-
- Closed
-
Thanks for the dump.
While it doesn't match the story to the teeth, I think I've eventually managed to figure out most of what had happened.
You must have had this database from around 10.1 or so.
Some time then, in order to get rid of InnoDB, you altered a few system tables which had InnoDB for an engine. Importantly, you changed innodb_table_stats and innodb_index_stats tables to MyISAM.
In 10.2+, the tables' structures were modified, particularly one of columns was enlarged. For innodb_index_stats this column is a part of an index, and the new column length makes the index too long for MyISAM (it is still fine with InnoDB).
mysql_upgrade script takes into account the possibility that InnoDB doesn't exist in the system, and doesn't attempt to touch its tables then, but it cannot guess that tables which belong to InnoDB by nature can have some other engine, so this error is not anticipated.
At least by doing it this way (altering the tables to MyISAM on 10.1 and then running upgrade on any higher version), I get the same error. The line numbers differ depending on the version, with 10.4 it matches yours exactly.
Phase 4/7: Running 'mysql_fix_privilege_tables'
ERROR 1071 (42000) at line 437: Specified key was too long; max key length is 1000 bytes
FATAL ERROR: Upgrade failed
The failing statement is this:
What I couldn't quite figure out is where mysql.innodb_index_stats table disappeared after the upgrade, as it isn't present in your dump. Another table, mysql.innodb_table_stats, is there, and it is indeed MyISAM, but innodb_index_stats, which causes the failure, isn't there at all. Maybe it disappeared during further failed attempts to upgrade, or maybe you dropped it later.
You should have seen this error in 10.2 already, but maybe you ran upgrade without InnoDB. And 10.3 apparently skipped mysql_upgrade, otherwise you wouldn't have the error about mysql.proc in the log on 10.4.
So mainly it's an issue of the customized configuration. But I want to keep this report open, because after dealing with it, there are at least two complaints I fully agree with.
First, mysql_upgrade needs to provide a much better message. I don't yet know how exactly it can be achieved, as it just runs the SQL script, but it's badly needed. Printing the failing statement would be very helpful, while the line number isn't at all, it doesn't match line numbers in either mysql_fix_privilege_tables.sql or scripts/mysql_system_tables_fix.sql or scripts/mysql_fix_privilege_tables_sql.c.
Secondly, while mysql_upgrade claims that it encountered a FATAL error and aborted, in fact it does a lot of stuff afterwards. That's why the general log is useless too, the failed statement is nowhere near the end of it.
So, I'm going to modify the summary of this bug to indicate that it's about mysql_upgrade failing without proper diagnostics.
For resolving the original issue, once you decide to customize you system tables, you have to stay consistent about it. In this case, inconsistency was in changing InnoDB-specific tables to MyISAM rather than dropping them, and then switching InnoDB back on. I think it's rather fortunate that it complained so early, I don't even know how InnoDB would behave when its system tables turned out to be outside the engine.