Bug #43904 server crash when `mysql`.`servers` table is converted to innodb
Submitted: 27 Mar 2009 10:09 Modified: 10 Dec 2010 23:20
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.32, 5.1.46, 6.0 bzr OS:Any
Assigned to: CPU Architecture:Any

[27 Mar 2009 10:09] Shane Bester
Description:
after mysql.servers table got converted to innodb, the server crashes on startup.

mysqld-debug.exe!strlen()[strlen.asm:81]
mysqld-debug.exe!get_server_from_table_to_cache()[sql_servers.cc:304]
mysqld-debug.exe!servers_load()[sql_servers.cc:190]
mysqld-debug.exe!servers_reload()[sql_servers.cc:249]
mysqld-debug.exe!servers_init()[sql_servers.cc:149]
mysqld-debug.exe!win_main()[mysqld.cc:4314]
mysqld-debug.exe!mysql_service()[mysqld.cc:4439]
mysqld-debug.exe!main()[mysqld.cc:4612]
mysqld-debug.exe!__tmainCRTStartup()[crt0.c:327]
mysqld-debug.exe!mainCRTStartup()[crt0.c:196]
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlInitializeExceptionChain()
ntdll.dll!RtlInitializeExceptionChain()

How to repeat:
CREATE SERVER fedlink FOREIGN DATA WRAPPER mysql
OPTIONS (USER 'fed_user', HOST 'remote_host', PORT 9306, DATABASE 'federated');

alter table mysql.servers engine=innodb;

now shutdown and restart mysqld server. crash happens

Suggested fix:
those tables should be myisam, and this is documented for years.  but, there's some better error checking that could be done to avoid a crash.
[27 Mar 2009 10:24] MySQL Verification Team
the problem is most likely much broader than this bug report claims - and applies to other tables in `mysql` database also.  firstly, the engine must be myisam, then number of columns should be correct, and finally the column type must be good.  

so, it's best to not give people rights in the mysql database.
[27 Mar 2009 10:39] Sveta Smirnova
Thank you for the report.

Verified as described. Backtrace on Linux:

stack_bottom = 0xbfc7be50 thread_stack 0x30c00
../libexec/mysqld(my_print_stacktrace+0x32) [0x8825afe]
../libexec/mysqld(handle_segfault+0x2f2) [0x82bf2c0]
[0x2ce420]
../libexec/mysqld [0x84cb7db]
../libexec/mysqld(servers_reload(THD*)+0x166) [0x84cd4e4]
../libexec/mysqld(servers_init(bool)+0x184) [0x84cd6f8]
../libexec/mysqld(main+0x310) [0x82c7950]
/lib/libc.so.6(__libc_start_main+0xdf) [0x301d7f]
../libexec/mysqld(__gxx_personality_v0+0x135) [0x81db021]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at (nil) is an invalid pointer
thd->thread_id=0
thd->killed=NOT_KILLED

I believe it is safe to check such errors at startup and would not lead to dramatical performance decrease, so I changed severity to S3.
[23 Apr 2009 9:33] MySQL Verification Team
if the time_zone* tables are converted to innodb, server also crashes when accessing them, e.g. calling CONVERT_TZ() function...