[MDEV-14008] Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op()) Created: 2017-10-05  Updated: 2018-05-30  Resolved: 2017-12-18

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.0, 10.1, 10.2.9, 10.3.2
Fix Version/s: 10.0.34, 10.1.30, 10.2.12, 10.3.3

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
causes MDEV-15352 AUTO_INCREMENT breaks after updating ... Closed
Relates
relates to MDEV-14661 CAST from double to UNSIGNED does not... Open

 Description   

10.2.9-MariaDB-debug version, failing assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op()).
test case (from mysql 5.6.37 innodb/innodb-autoinc.test)

CREATE TABLE t1 (c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
AUTO_INCREMENT=10000000000000000000;
INSERT INTO t1 VALUES ();

Version: '10.2.9-MariaDB-debug'  socket: '/tmp/mysql.sock'  port: 3322  Source distribution
mysqld: /home/alice/git/10.2/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
171005 14:58:37 [ERROR] 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.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
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.
 
Server version: 10.2.9-MariaDB-debug
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=7
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467371 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x7f9784000a98
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 = 0x7f97ecc3cec0 thread_stack 0x49000
/data/bld/10.2/bin/mysqld(my_print_stacktrace+0x38)[0x55d66ef35907]
/data/bld/10.2/bin/mysqld(handle_fatal_signal+0x3a3)[0x55d66e7c724a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f97f0c18390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f97effd1428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f97effd302a]
mysys/stacktrace.c:267(my_print_stacktrace)[0x7f97effc9bd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f97effc9c82]
sql/sql_error.cc:385(Diagnostics_area::set_ok_status(unsigned long long, unsigned long long, char const*))[0x55d66e52cd9f]
/data/bld/10.2/bin/mysqld(_Z5my_okP3THDyyPKc+0x4e)[0x55d66e4dfca3]
/data/bld/10.2/bin/mysqld(_Z12mysql_insertP3THDP10TABLE_LISTR4ListI4ItemERS3_IS5_ES6_S6_15enum_duplicatesb+0x17fb)[0x55d66e5352d8]
/data/bld/10.2/bin/mysqld(_Z21mysql_execute_commandP3THD+0x436a)[0x55d66e55bde9]
/data/bld/10.2/bin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x2a2)[0x55d66e5672d7]
/data/bld/10.2/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0xfee)[0x55d66e554c75]
sql/sql_class.h:4401(my_ok(THD*, unsigned long long, unsigned long long, char const*))[0x55d66e5535e8]
sql/sql_connect.cc:1354(do_handle_one_connection(CONNECT*))[0x55d66e6a0768]
sql/sql_connect.cc:1261(handle_one_connection)[0x55d66e6a04e8]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f97f0c0e6ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f97f00a33dd]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f9784017a00): INSERT INTO t1 VALUES ()
Connection ID (thread ID): 8
Status: NOT_KILLED

stack trace

Thread 1 (Thread 0x7f97ecc3d700 (LWP 32428)):
#0  0x00007f97effd1428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007f97effd302a in __GI_abort () at abort.c:89
#2  0x00007f97effc9bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x55d66efc24e0 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=file@entry=0x55d66efc2410 "/home/alice/git/10.2/sql/sql_error.cc", line=line@entry=380, function=function@entry=0x55d66efc2840 <Diagnostics_area::set_ok_status(unsigned long long, unsigned long long, char const*)::__PRETTY_FUNCTION__> "void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*)") at assert.c:92
#3  0x00007f97effc9c82 in __GI___assert_fail (assertion=0x55d66efc24e0 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=0x55d66efc2410 "/home/alice/git/10.2/sql/sql_error.cc", line=380, function=0x55d66efc2840 <Diagnostics_area::set_ok_status(unsigned long long, unsigned long long, char const*)::__PRETTY_FUNCTION__> "void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*)") at assert.c:101
#4  0x000055d66e52cd9f in Diagnostics_area::set_ok_status (this=0x7f9784005cb0, affected_rows=1, last_insert_id=10000000000000000000, message=0x0) at /home/alice/git/10.2/sql/sql_error.cc:380
#5  0x000055d66e4dfca3 in my_ok (thd=0x7f9784000a98, affected_rows=1, id=10000000000000000000, message=0x0) at /home/alice/git/10.2/sql/sql_class.h:4400
#6  0x000055d66e5352d8 in mysql_insert (thd=0x7f9784000a98, table_list=0x7f9784017f60, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /home/alice/git/10.2/sql/sql_insert.cc:1215
#7  0x000055d66e55bde9 in mysql_execute_command (thd=0x7f9784000a98) at /home/alice/git/10.2/sql/sql_parse.cc:4411
#8  0x000055d66e5672d7 in mysql_parse (thd=0x7f9784000a98, rawbuf=0x7f9784017a00 "INSERT INTO t1 VALUES ()", length=24, parser_state=0x7f97ecc3c240, is_com_multi=false, is_next_command=false) at /home/alice/git/10.2/sql/sql_parse.cc:7875
#9  0x000055d66e554c75 in dispatch_command (command=COM_QUERY, thd=0x7f9784000a98, packet=0x7f9784007e99 "INSERT INTO t1 VALUES ()", packet_length=24, is_com_multi=false, is_next_command=false) at /home/alice/git/10.2/sql/sql_parse.cc:1812
#10 0x000055d66e5535e8 in do_command (thd=0x7f9784000a98) at /home/alice/git/10.2/sql/sql_parse.cc:1360
#11 0x000055d66e6a0768 in do_handle_one_connection (connect=0x55d6722cedd8) at /home/alice/git/10.2/sql/sql_connect.cc:1354
#12 0x000055d66e6a04e8 in handle_one_connection (arg=0x55d6722cedd8) at /home/alice/git/10.2/sql/sql_connect.cc:1260
#13 0x00007f97f0c0e6ba in start_thread (arg=0x7f97ecc3d700) at pthread_create.c:333
#14 0x00007f97f00a33dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

results in MariaDB 10.0

MariaDB [test]> INSERT INTO t1 VALUES ();
Query OK, 1 row affected, 1 warning (0.07 sec)
MariaDB [test]> show warnings;
+---------+------+-------------------------------------------+
| Level   | Code | Message                                   |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '1e19' |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)

in 10.2

ERROR 1467 (HY000): Failed to read auto-increment value from storage engine



 Comments   
Comment by Alexander Barkov [ 2017-12-15 ]

10.0 and 10.1 are also affected, with STRICT_ALL_TABLES set:

SET sql_mode=STRICT_ALL_TABLES;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
INSERT INTO t1 VALUES ();

Comment by Alexander Barkov [ 2017-12-20 ]

After the original patch, this script started to crash:

SET sql_mode=STRICT_ALL_TABLES;
CREATE OR REPLACE TABLE t1 (a DOUBLE PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (-1);

Generated at Thu Feb 08 08:10:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.