Bug #59226 5.1 plugin crashes during crash recovery of 5.5.8 database
Submitted: 30 Dec 2010 2:59 Modified: 30 Dec 2010 14:02
Reporter: Mark Callaghan Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: InnoDB Plugin storage engine Severity:S3 (Non-critical)
Version:5.1.52 OS:Any
Assigned to: CPU Architecture:Any
Tags: crash, innodb, plugin, recovery

[30 Dec 2010 2:59] Mark Callaghan
Description:
I crashed a somewhat idle 5.5.8 server rather than wait for a clean shutdown. Users were not connected but it was doing insert buffer merges and some dirty pages. I then tried to run crash recovery using 5.1.52 innodb plugin and that crashed.

Is this expected to work?

Version: '5.1.52'  socket: '/data/5152fastfree/var/mysql.sock'  port: 3306  Source distribution
101229 18:49:31  InnoDB: Assertion failure in thread 1189869888 in file ibuf/ibuf0ibuf.c line 1398
InnoDB: Failing assertion: comp <= 1
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html
InnoDB: about forcing recovery.
101229 18:49:31 - mysqld got signal 6 ;
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=8384512
read_buffer_size=131072
max_used_connections=1
max_threads=2000
threads_connected=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 4381531 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
/data/5152fastfree/libexec/mysqld(my_print_stacktrace+0x2e) [0x84091e]
/data/5152fastfree/libexec/mysqld(handle_segfault+0x31d) [0x59523d]
/lib64/libpthread.so.0 [0x316640de70]
/lib64/libc.so.6(gsignal+0x35) [0x3165c30155]
/lib64/libc.so.6(abort+0x110) [0x3165c31bf0]
/data/5152fastfree/libexec/mysqld [0x7180d6]
/data/5152fastfree/libexec/mysqld [0x71c960]
/data/5152fastfree/libexec/mysqld [0x71d0d1]
/data/5152fastfree/libexec/mysqld [0x71d25e]
/data/5152fastfree/libexec/mysqld [0x77120b]
/lib64/libpthread.so.0 [0x31664062f7]
/lib64/libc.so.6(clone+0x6d) [0x3165cd1e3d]
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.
101229 18:49:32 mysqld_safe Number of processes running now: 0
101229 18:49:32 mysqld_safe mysqld restarted
101229 18:49:32 mysqld_safe Number of processes running now: 0
101229 18:49:32 mysqld_safe mysqld restarted
101229 18:49:32 [Note] Flashcache bypass: disabled
101229 18:49:32 [Note] Flashcache setup error is : ioctl failed

-----

Using resolve_stack_dump

0x3165c30155 _end + 1693276445
0x3165c31bf0 _end + 1693283256
0x7180d6 ibuf_rec_get_volume + 1398
0x71c960 ibuf_get_merge_page_nos + 1040
0x71d0d1 ibuf_contract_ext + 641
0x71d25e ibuf_contract_for_n_pages + 62
0x77120b srv_master_thread + 2411
0x31664062f7 _end + 1701493439

static
ulint
ibuf_rec_get_volume(
/*================*/
        const rec_t*    ibuf_rec)/*!< in: ibuf record */
{
        dtype_t         dtype;
        ibool           new_format      = FALSE;
        ulint           data_size       = 0;
        ulint           n_fields;
        const byte*     types;
        const byte*     data;
        ulint           len;
        ulint           i;
        ulint           comp;

        ut_ad(ibuf_inside());
        ut_ad(rec_get_n_fields_old(ibuf_rec) > 2);

        data = rec_get_nth_field_old(ibuf_rec, 1, &len);

        if (len > 1) {
                /* < 4.1.x format record */

                ut_a(trx_doublewrite_must_reset_space_ids);
                ut_a(!trx_sys_multiple_tablespace_format);

                n_fields = rec_get_n_fields_old(ibuf_rec) - 2;

                types = rec_get_nth_field_old(ibuf_rec, 1, &len);

                ut_ad(len == n_fields * DATA_ORDER_NULL_TYPE_BUF_SIZE);
                comp = 0;
        } else {
                /* >= 4.1.x format record */

                ut_a(trx_sys_multiple_tablespace_format);
                ut_a(*data == 0);

                types = rec_get_nth_field_old(ibuf_rec, 3, &len);

                comp = len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE;

                ut_a(comp <= 1);   <------ the crash is here

How to repeat:
1) run the insert benchmark using mysql 5.5.8
2) after it finishes but before all ibuf entries are merged, kill mysqld
3) copy files to 5.1.52 innodb plugin database and try to run crash recovery
[30 Dec 2010 3:03] Mark Callaghan
The database table was created with:

innodb_file_per_table
innodb_file_format=barracuda
[30 Dec 2010 3:20] Mark Callaghan
The schema for the table with pending merges in the insert buffer

  `transactionid` int(11) NOT NULL AUTO_INCREMENT,
  `dateandtime` datetime DEFAULT NULL,
  `cashregisterid` int(11) NOT NULL,
  `customerid` int(11) NOT NULL,
  `productid` int(11) NOT NULL,
  `price` float NOT NULL,
  PRIMARY KEY (`transactionid`),
  KEY `marketsegment` (`price`,`customerid`),
  KEY `registersegment` (`cashregisterid`,`price`,`customerid`),
  KEY `pdc` (`price`,`dateandtime`,`customerid`)
) engine=innodb
[30 Dec 2010 3:21] Mark Callaghan
The insert benchmark code is at 
http://bazaar.launchpad.net/~mdcallag/mysql-patch/mytools/annotate/head:/bench/ibench/iibe...
[30 Dec 2010 9:20] Sveta Smirnova
Thank you for the report.

According to http://dev.mysql.com/doc/refman/5.5/en/downgrading.html:

If you downgrade from one release series to another, there may be incompatibilities in table storage formats. In this case, use mysqldump to dump your tables before downgrading. After downgrading, reload the dump file using mysql or mysqlimport to re-create your tables. 

So this is not a bug.
[30 Dec 2010 14:02] Mark Callaghan
I prefer dump & reload, but it is not required. Per the InnoDB docs a slow shutdown is required -- all dirty blocks must be written, all entries from the insert buffer must be merged, all pending transactions must commit or rollback. Expecting crash recovery to work violates all of those requirements.

This is definitely not a bug.