Bug #66836 Failing assertion: current <= max_value in ha_innodb.cc on out-of-range autoinc
Submitted: 16 Sep 2012 18:49 Modified: 17 Sep 2012 0:24
Reporter: Elena Stepanova Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.5.27 OS:Any
Assigned to: CPU Architecture:Any

[16 Sep 2012 18:49] Elena Stepanova
Description:
Version: '5.5.27-log'  
InnoDB: Assertion failure in thread 140594180294400 in file ha_innodb.cc line 1477
InnoDB: Failing assertion: current <= max_value

#4  0x00007fdea7cadb0b in __GI_abort () at abort.c:92
#5  0x00000000007f89e4 in innobase_next_autoinc (current=<optimized out>, need=<optimized out>, step=<optimized out>, offset=<optimized out>, max_value=<optimized out>) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/storage/innobase/handler/ha_innodb.cc:1477
#6  0x0000000000806245 in ha_innobase::get_auto_increment (this=0x2b6b8a0, offset=1, increment=1, nb_desired_values=1, first_value=0x7fdea22c6330, nb_reserved_values=0x7fdea22c6328) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/storage/innobase/handler/ha_innodb.cc:10208
#7  0x000000000067070e in handler::update_auto_increment (this=0x2b6b8a0) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/handler.cc:2560
#8  0x0000000000804229 in ha_innobase::write_row (this=0x2b6b8a0, record=0x2b40fd0 "\377") at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/storage/innobase/handler/ha_innodb.cc:5197
#9  0x00000000006734ec in handler::ha_write_row (this=0x2b6b8a0, buf=0x2b40fd0 "\377") at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/handler.cc:5128
#10 0x00000000005612b2 in write_record (thd=0x2aa89a0, table=0x2b406f0, info=0x7fdea22c6780) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/sql_insert.cc:1734
#11 0x0000000000567f97 in mysql_insert (thd=0x2aa89a0, table_list=0x2b34950, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/sql_insert.cc:931
#12 0x00000000005770af in mysql_execute_command (thd=0x2aa89a0) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/sql_parse.cc:2915
#13 0x000000000057b03a in mysql_parse (thd=0x2aa89a0, rawbuf=<optimized out>, length=<optimized out>, parser_state=0x7fdea22c7ba0) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/sql_parse.cc:5627
#14 0x000000000057cbe1 in dispatch_command (command=COM_QUERY, thd=0x2aa89a0, packet=<optimized out>, packet_length=28) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/sql_parse.cc:1037
#15 0x0000000000613447 in do_handle_one_connection (thd_arg=<optimized out>) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/sql_connect.cc:840
#16 0x00000000006134b4 in handle_one_connection (arg=<optimized out>) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/sql/sql_connect.cc:759
#17 0x00000000007f6abb in pfs_spawn_thread (arg=<optimized out>) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/storage/perfschema/pfs.cc:1015
#18 0x00007fdea8ae7efc in start_thread (arg=0x7fdea22c8700) at pthread_create.c:304
#19 0x00007fdea7d5759d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

Query (2b34860): INSERT INTO t1 VALUES (NULL)
Connection ID (thread ID): 2
Status: NOT_KILLED

How to repeat:
--source include/have_innodb.inc

CREATE TABLE t1 (i TINYINT AUTO_INCREMENT PRIMARY KEY) 
  ENGINE=InnoDB AUTO_INCREMENT=128;
INSERT INTO t1 VALUES (NULL);
[17 Sep 2012 0:24] MySQL Verification Team
Thank you for the bug report. I can repeat with 5.5.27 but not with 2 week older source server so it was fixed in some way:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

d:\dbs>5.5\bin\mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.29 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> CREATE TABLE t1 (i TINYINT AUTO_INCREMENT PRIMARY KEY)
    ->   ENGINE=InnoDB AUTO_INCREMENT=128;
Query OK, 0 rows affected (0.06 sec)

mysql> INSERT INTO t1 VALUES (NULL);
ERROR 1467 (HY000): Failed to read auto-increment value from storage engine
mysql>

---------------------------------------------------------------------------

d:\tmp\mysql-5.5.27-winx64>bin\mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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> CREATE TABLE t1 (i TINYINT AUTO_INCREMENT PRIMARY KEY)
    ->   ENGINE=InnoDB AUTO_INCREMENT=128;
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO t1 VALUES (NULL);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>

d:\tmp\mysql-5.5.27-winx64>bin\mysqld --standalone --console
120916 21:12:35 [Note] Plugin 'FEDERATED' is disabled.
120916 21:12:35 InnoDB: The InnoDB memory heap is disabled
120916 21:12:35 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120916 21:12:35 InnoDB: Compressed tables use zlib 1.2.3
120916 21:12:35 InnoDB: Initializing buffer pool, size = 128.0M
120916 21:12:35 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
120916 21:12:35  InnoDB: Setting file .\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
120916 21:12:35  InnoDB: Log file .\ib_logfile0 did not exist: new to be created
InnoDB: Setting log file .\ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
120916 21:12:35  InnoDB: Log file .\ib_logfile1 did not exist: new to be created
InnoDB: Setting log file .\ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
120916 21:12:36  InnoDB: Waiting for the background threads to start
120916 21:12:37 InnoDB: 1.1.8 started; log sequence number 0
120916 21:12:37 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
120916 21:12:37 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
120916 21:12:37 [Note] Server socket created on IP: '0.0.0.0'.
120916 21:12:37 [Note] Event Scheduler: Loaded 0 events
120916 21:12:37 [Note] bin\mysqld: ready for connections.
Version: '5.5.27'  socket: ''  port: 3306  MySQL Community Server (GPL)
120916 21:13:37  InnoDB: Assertion failure in thread 4716 in file ha_innodb.cc line 1477
InnoDB: Failing assertion: current <= max_value
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.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
00:13:37 UTC - mysqld got exception 0xc0000005 ;
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=8388608
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=1
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338319 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0xc557fd0
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...
13f3e6e76    mysqld.exe!innobase_next_autoinc()[ha_innodb.cc:1477]
13f3ef26a    mysqld.exe!ha_innobase::get_auto_increment()[ha_innodb.cc:10210]
13f1c3f54    mysqld.exe!handler::update_auto_increment()[handler.cc:2561]
13f3e9c27    mysqld.exe!ha_innobase::write_row()[ha_innodb.cc:5197]
13f1c65a6    mysqld.exe!handler::ha_write_row()[handler.cc:5130]
13f2f9446    mysqld.exe!write_record()[sql_insert.cc:1734]
13f2ffaf7    mysqld.exe!mysql_insert()[sql_insert.cc:931]
13f204453    mysqld.exe!mysql_execute_command()[sql_parse.cc:2915]
13f206f3a    mysqld.exe!mysql_parse()[sql_parse.cc:5632]
13f207d0c    mysqld.exe!dispatch_command()[sql_parse.cc:1040]
13f208b1c    mysqld.exe!do_command()[sql_parse.cc:773]
13f22e5f6    mysqld.exe!do_handle_one_connection()[sql_connect.cc:840]
13f22e6b4    mysqld.exe!handle_one_connection()[sql_connect.cc:761]
13f3b54ce    mysqld.exe!pthread_start()[my_winthread.c:63]
13f55c097    mysqld.exe!_callthreadstartex()[threadex.c:348]
13f55c14b    mysqld.exe!_threadstartex()[threadex.c:326]
7684652d    kernel32.dll!BaseThreadInitThunk()
76ddc521    ntdll.dll!RtlUserThreadStart()

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (c5e6ef0): INSERT INTO t1 VALUES (NULL)Connection ID (thread ID): 1
Status: 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.
InnoDB: Thread 6932 stopped in file os0sync.c line 474
InnoDB: Thread 6292 stopped in file os0sync.c line 781
InnoDB: Thread 5268 stopped in file os0sync.c line 474