跨版本导入数据导致mysqld崩溃
现象
mysqld突然崩溃,错误日志Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7fd06c41be28 thread_stack 0x40000
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(my_print_stacktrace+0x35)[0x8e37d5]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(handle_fatal_signal+0x41b)[0x651d0b]
/lib64/libpthread.so.0(+0xf500)[0x7fd1c9b2d500]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(_Z9get_fieldP11st_mem_rootP5Field+0x43)[0x769b43]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld[0x6768cc]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(_Z11mysql_grantP3THDPKcR4ListI11st_lex_userEmbb+0x4f1)[0x6785c1]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(_Z21mysql_execute_commandP3THD+0x4972)[0x6db4a2]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x531)[0x6dbb71]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1782)[0x6dd392]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(_Z24do_handle_one_connectionP3THD+0x10d)[0x6a572d]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(handle_one_connection+0x42)[0x6a5862]
/opt/udb/program/mysql/mysql-5.6.20/bin/mysqld(pfs_spawn_thread+0x127)[0xaf8d87]
/lib64/libpthread.so.0(+0x7851)[0x7fd1c9b25851]
/lib64/libc.so.6(clone+0x6d)[0x7fd1c8b9590d]
原因分析
通过错误查看到(_Z11mysql_grantP3THDPKcR4ListI11st_lex_userEmbb+0x4f1),mysql_grant函数调用导致崩溃,猜测是用户授权时出了问题,重新登录db发现user表结构确实有问题,下图中1是崩溃后的表结构,2是该mysqld版本对应的user表结构故障模拟
1 新建一个正常的db,表结构应该是上图中的22 删除user表,新建表结构1
3 执行grant语法创建一个新账户,这时mysqld就崩溃了
改进措施
1 任何跨版本导入数据,一定要执行mysql_upgrade2 有些情况下mysql_upgrade还不一定够用,需要额外再去检查系统表有无问题,故障案例参见
http://blog.****.net/cug_jiang126com/article/details/51602757