Bug #41404 pthread related segfault
Submitted: 11 Dec 2008 17:07 Modified: 27 Jul 2009 16:34
Reporter: Adam Erickson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.1.30 OS:Linux (2.6.18-53.1.14.el5 (SMP, 64 bit))
Assigned to: CPU Architecture:Any
Tags: crash, mysqld, pthreads, segfault

[11 Dec 2008 17:07] Adam Erickson
Description:
Looks like a pthread issue.  Nothing significiant had changed in the environment, this was completely "random."

After the crash, mysqld_safe attempts to restart the server but InnoDB fails (see farther down for that error.)  We had to restore the InnoDB tables from backups.

------ Error Log at time of crash ------
Status information:

Current dir: /db/espdbmst/
Running threads: 25  Stack size: 262144
Current locks:
lock: 0x39f8ac8: write
write     : 0x39e9e48 (6519:12);

081211  4:02:08 - 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=4294967296
read_buffer_size=4194304
max_used_connections=27
max_threads=300
threads_connected=25
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 6654953 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x0
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 = (nil) thread_stack 0x40000
/opt/mysql/bin/mysqld(my_print_stacktrace+0x20) [0x9fa460]
/opt/mysql/bin/mysqld(handle_segfault+0x368) [0x5fa992]
/lib64/libpthread.so.0 [0x346ac0de70]
/lib64/libc.so.6(strlen+0x10) [0x3469c76150]
/lib64/libc.so.6(_IO_vfprintf+0x3e9b) [0x3469c4605b]
/lib64/libc.so.6(_IO_printf+0x9a) [0x3469c4be6a]
/opt/mysql/bin/mysqld(mysql_print_status()+0x541) [0x6b129d]
/opt/mysql/bin/mysqld(signal_hand+0x29f) [0x5f8d57]
/lib64/libpthread.so.0 [0x346ac062f7]
/lib64/libc.so.6(clone+0x6d) [0x3469cce85d]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

Key caches:
default
Buffer_size:    4294967296
Block_size:           1024
Division_limit:        100
Age_limit:             300
blocks used:        815156
not flushed:             0
w_requests:       52749072
writes:            6854725
r_requests:      302379447
reads:              709249

handler status:
read_key:       543228
read_next:    48712552
read_rnd         74368
read_first:         27
write:        50844365
delete          163350
update:        1106464

Table status:
Opened tables:        186
Open tables:            1
Open files:             4
Open streams:           0

Alarm status:
Active alarms:   24
Max used alarms: 27
Next alarm time: 187

Thread database.table_name          Locked/Waiting        Lock_type

6519    om_chart.qt_corax_split_recoLocked - write        

---- InnoDB Recovery attempt failure, server never comes back online ----
081211 04:02:08 mysqld
_safe Number of processes running now: 0
081211 04:02:08 mysqld_safe mysqld restarted
081211  4:02:08 [Warning] The syntax '--log' is deprecated and will be removed i
n MySQL 7.0. Please use '--general_log'/'--general_log_file' instead.
081211  4:02:08 [Warning] The syntax '--log_slow_queries' is deprecated and will
 be removed in MySQL 7.0. Please use '--slow_query_log'/'--slow_query_log_file'
instead.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
081211  4:02:10  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Page directory corruption: infimum not pointed to
081211  4:02:10  InnoDB: Page dump in ascii and hex (16384 bytes):
 len 16384; hex (( Long string of Zeros ))
; asc ((Long string of spaces ))
 ;InnoDB: End of page dump
081211  4:02:10  InnoDB: Page checksum 1575996416, prior-to-4.0.14-form checksum
 1371122432
InnoDB: stored checksum 0, prior-to-4.0.14-form stored checksum 0
InnoDB: Page lsn 0 0, low 4 bytes of lsn at page end 0
InnoDB: Page number (if stored to page already) 0,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be a freshly allocated page
InnoDB: Page directory corruption: supremum not pointed to
081211  4:02:10  InnoDB: Page dump in ascii and hex (16384 bytes):
 len 16384; hex (( Long string of Zeros ))
; asc ((Long string of spaces ))
 ;InnoDB: End of page dump
081211  4:02:10  InnoDB: Page checksum 1575996416, prior-to-4.0.14-form checksum
 1371122432
InnoDB: stored checksum 0, prior-to-4.0.14-form stored checksum 0
InnoDB: Page lsn 0 0, low 4 bytes of lsn at page end 0
InnoDB: Page number (if stored to page already) 0,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be a freshly allocated page
081211  4:02:10 - 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=4294967296
read_buffer_size=4194304
max_used_connections=0
max_threads=300
threads_connected=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 6654953 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x0
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 = (nil) thread_stack 0x40000
/opt/mysql/bin/mysqld(my_print_stacktrace+0x20) [0x9fa460]
/opt/mysql/bin/mysqld(handle_segfault+0x368) [0x5fa992]
/lib64/libpthread.so.0 [0x346ac0de70]
/opt/mysql/bin/mysqld(page_cur_search_with_match+0x476) [0x8e8c9a]
/opt/mysql/bin/mysqld(btr_cur_search_to_nth_level+0xb0c) [0x83af74]
/opt/mysql/bin/mysqld(btr_pcur_open_on_user_rec+0x4a) [0x96666e]
/opt/mysql/bin/mysqld [0x8711e9]
/opt/mysql/bin/mysqld(dict_load_sys_table+0x54) [0x86de0c]
/opt/mysql/bin/mysqld(dict_boot+0x8e4) [0x96b7ce]
/opt/mysql/bin/mysqld(innobase_start_or_create_for_mysql+0x18e0) [0x92c648]
/opt/mysql/bin/mysqld [0x831fdf]
/opt/mysql/bin/mysqld(ha_initialize_handlerton(st_plugin_int*)+0x31) [0x740d9b]
/opt/mysql/bin/mysqld [0x7f3e5d]
/opt/mysql/bin/mysqld(plugin_init(int*, char**, int)+0xe4f) [0x7f3dc1]
/opt/mysql/bin/mysqld(main+0xb40) [0x5f5264]
/lib64/libc.so.6(__libc_start_main+0xf4) [0x3469c1d8a4]
/opt/mysql/bin/mysqld [0x4f007a]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
081211 04:02:10 mysqld_safe mysqld from pid file /var/lock/mysql.espdbmst.pid en
ded

How to repeat:
Nothing substantial had changed in our enviornment.  The queries in the query log around the time of the crash were not unusual and have run without causing problems before.

There was a XA transaction in place at the time of the crash and the server had recently received a SIGHUP for log rotation.

Otherwise I have no idea how to repeat this.

Suggested fix:
Fail to crash.
[12 Jan 2009 12:20] MySQL Verification Team
Adam, this crash happened in mysql_print_status().  This function is called when somebody runs "mysqladmin -uroot debug" or mysqld receives a SIGHUP.  See bug #34502 for a similar crash.

Do you know if anybody calls mysqladmin debug on a regular basis?
[12 Jan 2009 12:23] MySQL Verification Team
I'm guessing the innodb corruption was a result of the first crash
[12 Jan 2009 14:18] Adam Erickson
I am 99% sure nobody here would be using that.
[12 Jan 2009 14:22] Adam Erickson
A small clarification, nobody here would have been using mysqladmin debug.  We are using InnoDB.
[12 Jan 2009 14:58] MySQL Verification Team
The SIGHUP would have had the same affect as "mysqladmin debug", so I think this is just another manifestation as the bug I referred to.

pthread_handler_t signal_hand(void *arg __attribute__((unused)))
{
cut>
case SIGHUP:
      if (!abort_loop)
      {
        bool not_used;
	mysql_print_status();		// Print some debug info
	reload_acl_and_cache((THD*) 0,
			     (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
			      REFRESH_GRANT |
			      REFRESH_THREADS | REFRESH_HOSTS),
			     (TABLE_LIST*) 0, &not_used); // Flush logs
      }
      /* reenable logs after the options were reloaded */
      if (log_output_options & LOG_NONE)
      {
        logger.set_handlers(LOG_FILE,
                            opt_slow_log ? LOG_TABLE : LOG_NONE,
                            opt_log ? LOG_TABLE : LOG_NONE);
      }
<cut>
[12 Jan 2009 15:35] Adam Erickson
We are sending SIGHUP daily for log rotation so that seems plausible.  We don't get server crashes from it though.
[25 Mar 2009 21:00] Adam Erickson
Easily reproduced in my environment via:

CREATE DATABSE test;
USE test;
CREATE TABLE foo ( a int );
LOCK TABLE foo WRITE;
(Send mysqld SIGHUP now, crash)
[27 Jul 2009 16:29] Adam Erickson
A simple test case has been provided.  No response for seven months.  Any update?
[27 Jul 2009 16:34] Adam Erickson
Appears to be fixed in 5.1.35.