Bug #56982 Assertion Failure from ha_innobase::innobase_peek_autoinc() when auto_inc > 0
Submitted: 23 Sep 2010 20:42 Modified: 14 Dec 2010 19:59
Reporter: Chris Calender Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.1.50 OS:Any
Assigned to: Sunny Bains CPU Architecture:Any
Tags: assertion failure, AUOTINC, auto_inc > 0, innobase_peek_autoinc, MySQL and InnoDB data dictionaries are out of sync

[23 Sep 2010 20:42] Chris Calender
Description:
When the MySQL and InnoDB data dictionaries are out of sync with respect to an AUTOINC column, then InnoDB will throw an assertion failure the next time a command is given that calls ha_innobase::innobase_peek_autoinc().

100920 14:11:24  InnoDB: MySQL and InnoDB data dictionaries are out of sync.
InnoDB: Unable to find the AUTOINC column Id in the InnoDB table quad/Configurations.
InnoDB: We set the next AUTOINC column value to 0,
InnoDB: in effect disabling the AUTOINC next value generation.
InnoDB: You can either set the next AUTOINC value explicitly using ALTER TABLE
InnoDB: or fix the data dictionary by recreating the table.
100920 14:11:24  InnoDB: Assertion failure in thread 16 in file handler/ha_innodb.cc line 7972
InnoDB: Failing assertion: auto_inc > 0
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.
100920 14:11:24 - 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=262144000
read_buffer_size=262144
max_used_connections=37
max_threads=151
threads_connected=36
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 305854 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x1271a2b28
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...
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:my_print_stacktrace+0x1c
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:handle_segfault+0x290
/lib/sparcv9/libc.so.1:0xd65b4
/lib/sparcv9/libc.so.1:0xca104
/lib/sparcv9/libc.so.1:0xca310
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cLha_innobaseVinnobase_peek_autoinc6M_X_+0x164 [ Signal 11 (SEGV)]
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cLha_innobaseEinfo6MI_i_+0x500
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:0x34e954
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cOget_all_tables6FpnDTHD_pnKTABLE_LIST_pnEItem__i_+0xd84
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cYget_schema_tables_result6FpnEJOIN_nXenum_schema_table_state__b_+0x1b0
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cEJOINEexec6M_v_+0x448
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cMmysql_select6FpnDTHD_pppnEItem_pnKTABLE_LIST_IrnEList4n0B___p2IpnIst_order_9D39DXpnNselect_result_pnSst_select_lex_unit_pnNst_select_lex__b_+0x39c
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cNhandle_select6FpnDTHD_pnGst_lex_pnNselect_result_L_b_+0xec
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:0x2471f8
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cVmysql_execute_command6FpnDTHD__i_+0x6fc
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cLmysql_parse6FpnDTHD_pkcIp3_v_+0x1a4
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cQdispatch_command6FnTenum_server_command_pnDTHD_pcI_b_+0x7ac
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:__1cKdo_command6FpnDTHD__b_+0xe0
/u01/app/mysql/mysql-enterprise-gpl-5.1.49-solaris10-sparc-64bit/bin/mysqld:handle_one_connection+0x168
/lib/sparcv9/libc.so.1:0xd6488
Please read http://dev.mysql.com/doc/refman/5.1/en/resolve-stack-dump.html
and follow instructions on how to resolve the stack trace.
Resolved stack trace is much more helpful in diagnosing the
problem, so please do resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 11d8b46a0 = select table_schema,table_name,table_rows,engine,avg_row_length,update_time from information_schema.tables where table_schema NOT IN ('information_schema','mysql')
thd->thread_id=283
thd->killed=NOT_KILLED
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.
100920 14:11:24 mysqld_safe mysqld restarted...

How to repeat:
1. ALTER TABLE ... -- that results in the InnoDB DD and .frm files to get out of sync. (This is not necessarily easy to accomplish, but could occur if there was a crash during an ALTER TABLE operation or renamed the autoinc column.

2. Restart

3. SHOW CREATE TABLE autonic_table; -- or whatever is the equivalent that  results in a call to ha_innobase::innobase_peek_autoinc(). (Even a SELECT FROM I_S tables could lead to this, such as in the above stack trace).

Suggested fix:
Remove the assertion on ha_innobase::innobase_peek_autoinc() and spam the log with a message similar to the one printed when we initialize the autoinc value during a table open.
[9 Nov 2010 19:45] Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (merge vers: 5.5.7-rc) (pib:21)
[13 Nov 2010 16:12] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:33] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)
[18 Nov 2010 15:55] Bugs System
Pushed into mysql-5.1 5.1.54 (revid:build@mysql.com-20101118153531-693taxtxyxpt037i) (version source revid:build@mysql.com-20101118153531-693taxtxyxpt037i) (merge vers: 5.1.54) (pib:21)
[5 Dec 2010 12:39] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)
[14 Dec 2010 19:59] John Russell
Added to change log:

If the server crashed during an ALTER TABLE operation on an InnoDB
table, examining the table through SHOW CREATE TABLE or querying the
INFORMATION_SCHEMA tables could cause the server to stop with an
assertion error.
[16 Dec 2010 22:33] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)