Bug #66008 MySQL crashes during manual insert into mysql.servers table
Submitted: 25 Jul 2012 10:22 Modified: 27 Jul 2012 12:45
Reporter: Vyacheslav Gritsenko Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S1 (Critical)
Version:5.1, 5.5, 5.6.7 OS:Linux (tested on CentOS-6.3)
Assigned to: CPU Architecture:Any
Tags: crash, federated, mysql.servers

[25 Jul 2012 10:22] Vyacheslav Gritsenko
Description:
I didn't notice any issues using CREATE SERVERS statement, but if I want to manually update mysql.servers table and insert some single string into *host* field, it results to server crash, just don't forget to run "flush privileges" afterwards.
The main issue is that server will not start anymore until you fix(re-create / restore from backups) mysql.servers table. Server just keeps restarting.
Replicated using MySQL-5.1 and MySQL-5.5.

How to repeat:
It's very simple to repeat:

mysql> select * from mysql.servers;
Empty set (0.00 sec)

mysql> insert into mysql.servers set host='sfdsfsfsdf';
Query OK, 1 row affected (0.00 sec)

mysql> flush privileges;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> status;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR:
Can't connect to the server

mysql>

+++++++++++++++++++++++++++++++

Error log entry is below:

120725 06:05:52 mysqld_safe Number of processes running now: 0
120725 06:05:52 mysqld_safe mysqld restarted
120725  6:05:52 [Warning] You need to use --log-bin to make --binlog-format work.
120725  6:05:52 [Note] Plugin 'FEDERATED' is disabled.
120725  6:05:52 InnoDB: The InnoDB memory heap is disabled
120725  6:05:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120725  6:05:52 InnoDB: Compressed tables use zlib 1.2.3
120725  6:05:52 InnoDB: Using Linux native AIO
120725  6:05:52 InnoDB: Initializing buffer pool, size = 2.5G
120725  6:05:52 InnoDB: Completed initialization of buffer pool
120725  6:05:52 InnoDB: highest supported file format is Barracuda.
120725  6:05:52  InnoDB: Waiting for the background threads to start
120725  6:05:53 InnoDB: 1.1.8 started; log sequence number 86171321771
120725  6:05:53 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
120725  6:05:53 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
120725  6:05:53 [Note] Server socket created on IP: '0.0.0.0'.
10:05:53 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=402653184
read_buffer_size=2097152
max_used_connections=0
max_threads=60000
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 246838528 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7865820
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 = 7fff60551388 thread_stack 0x40000
/usr/local/mysql/bin/mysqld(my_print_stacktrace+0x35)[0x79d255]
/usr/local/mysql/bin/mysqld(handle_fatal_signal+0x403)[0x66d383]
/lib64/libpthread.so.0[0x3ebee0f500]
/lib64/libc.so.6[0x3ebe731aff]
/usr/local/mysql/bin/mysqld[0x60f5c4]
/usr/local/mysql/bin/mysqld(_Z14servers_reloadP3THD+0x1ab)[0x60fecb]
/usr/local/mysql/bin/mysqld(_Z12servers_initb+0x121)[0x610041]
/usr/local/mysql/bin/mysqld(_Z11mysqld_mainiPPc+0xbf5)[0x507d45]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x3ebe61ecdd]
/usr/local/mysql/bin/mysqld[0x4fd38a]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0): is an invalid pointer
Connection ID (thread ID): 0
Status: NOT_KILLED

Suggested fix:
?
[25 Jul 2012 11:30] Valeriy Kravchuk
Thank you for the bug report. Same with 5.6:

[openxs@chief 5.6]$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.7-debug Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from mysql.servers;
Empty set (0.00 sec)

mysql> insert into mysql.servers set host='sfdsfsfsdf';
Query OK, 1 row affected (0.00 sec)

mysql> flush privileges;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 120725 14:28:19 mysqld_safe Number of processes running now: 0
120725 14:28:19 mysqld_safe mysqld restarted
120725 14:28:21 mysqld_safe Number of processes running now: 0
120725 14:28:21 mysqld_safe mysqld restarted
[25 Jul 2012 14:23] MySQL Verification Team
Could be a duplicate of this?
Bug#14220942: DDL ON SERVERS WITH ZERO LENGTH NAME CRASHES SERVER!
[4 Sep 2012 8:52] Raghavendra Prabhu
Is this bug a duplicate or has this been fixed to mark it closed? I tested on 5.5.27 and could replicate this.
[4 Sep 2012 10:12] MySQL Verification Team
from what I see it was only fixed in 5.6.7 and 5.7.0 versions.