[MDEV-17556] Assertion `bitmap_is_set_all(&table->s->all_set)' failed in handler::ha_reset upon SELECT under READ UNCOMMITTED from table with index on virtual column Created: 2018-10-26  Updated: 2021-02-01  Resolved: 2021-01-26

Status: Closed
Project: MariaDB Server
Component/s: Virtual Columns
Affects Version/s: 10.2, 10.3, 10.5, 10.6
Fix Version/s: 10.2.37, 10.3.28, 10.4.18, 10.5.9

Type: Bug Priority: Blocker
Reporter: Elena Stepanova Assignee: Nikita Malyavin
Resolution: Fixed Votes: 0
Labels: affects-tests


 Description   

--source include/have_innodb.inc
 
CREATE TABLE t1 ( 
  a INT,
  b INT,
  c INT,
  v INT AS (a) VIRTUAL,
  INDEX(c,v)
) ENGINE=InnoDB;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
INSERT INTO t1 (c) VALUES (9);
SELECT * FROM t1 WHERE c BETWEEN 1 AND 6 ORDER BY b;
 
# Cleanup
DROP TABLE t1;

10.2 53440e2dda8b3

mysqld: /data/src/10.2/sql/handler.cc:5931: int handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed.
181209 22:22:53 [ERROR] mysqld got signal 6 ;
 
#7  0x00007ffa1c4ddee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000555ceacfbeaa in handler::ha_reset (this=0x7ff9c4009d28) at /data/src/10.2/sql/handler.cc:5931
#9  0x0000555cea9ffdb1 in close_thread_table (thd=0x7ff9c4000b00, table_ptr=0x7ff9c4000be0) at /data/src/10.2/sql/sql_base.cc:894
#10 0x0000555cea9ffb2f in close_thread_tables (thd=0x7ff9c4000b00) at /data/src/10.2/sql/sql_base.cc:851
#11 0x0000555ceaa7db98 in mysql_execute_command (thd=0x7ff9c4000b00) at /data/src/10.2/sql/sql_parse.cc:6305
#12 0x0000555ceaa82725 in mysql_parse (thd=0x7ff9c4000b00, rawbuf=0x7ff9c4012448 "SELECT * FROM t1 WHERE c BETWEEN 1 AND 6 ORDER BY b", length=51, parser_state=0x7ffa14148200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8013
#13 0x0000555ceaa7005d in dispatch_command (command=COM_QUERY, thd=0x7ff9c4000b00, packet=0x7ff9c40960c1 "", packet_length=51, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1824
#14 0x0000555ceaa6e9c0 in do_command (thd=0x7ff9c4000b00) at /data/src/10.2/sql/sql_parse.cc:1378
#15 0x0000555ceabc1131 in do_handle_one_connection (connect=0x555cee91ee20) at /data/src/10.2/sql/sql_connect.cc:1335
#16 0x0000555ceabc0ebe in handle_one_connection (arg=0x555cee91ee20) at /data/src/10.2/sql/sql_connect.cc:1241
#17 0x0000555ceafe6b88 in pfs_spawn_thread (arg=0x555cee86a2d0) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#18 0x00007ffa1df99494 in start_thread (arg=0x7ffa14149700) at pthread_create.c:333
#19 0x00007ffa1c59a93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

No visible effect on a non-debug build.



 Comments   
Comment by Alice Sherepa [ 2019-03-04 ]

mysqld: /10.4/sql/handler.cc:6450: int handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed.
 
stdlib/abort.c:91(__GI_abort)[0x7f7fd37cec82]
/10.4/sql/mysqld(_ZN7handler8ha_resetEv+0x3ed)[0x55fb10dfc87f]
/10.4/sql/mysqld(_Z18close_thread_tableP3THDPP5TABLE+0x77b)[0x55fb1050c13c]
sql/handler.cc:6451(handler::ha_reset())[0x55fb1050b93a]
sql/sql_base.cc:1029(close_thread_table(THD*, TABLE**))[0x55fb10a06926]
sql/sql_base.cc:972(close_thread_tables(THD*))[0x55fb10a07710]
sql/sql_admin.cc:1185(mysql_admin_table(THD*, TABLE_LIST*, st_ha_check_opt*, char const*, thr_lock_type, bool, bool, unsigned int, int (*)(THD*, TABLE_LIST*, st_ha_check_opt*), int (handler::*)(THD*, st_ha_check_opt*), int (*)(THD*, TABLE_LIST*, st_ha_check_opt*)))[0x55fb10687fe5]
sql/sql_admin.cc:1315(Sql_cmd_analyze_table::execute(THD*))[0x55fb10692825]
sql/sql_parse.cc:6346(mysql_execute_command(THD*))[0x55fb1066b2d2]
sql/sql_parse.cc:8157(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55fb106681cd]
sql/sql_parse.cc:1831(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55fb109dc460]
sql/sql_parse.cc:1358(do_command(THD*))[0x55fb109dbe2a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f7fd46176ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f7fd38a841d]

Comment by Roel Van de Paar [ 2020-09-26 ]

Sporadic issue, execute about 200 times orso

DROP DATABASE test;
CREATE DATABASE test;
USE test;
SET SQL_MODE='';
CREATE TABLE t (a INT(11) DEFAULT NULL, b INT(11) DEFAULT NULL, c INT(11) GENERATED ALWAYS AS (a+b) VIRTUAL, x INT(11) NOT NULL, h VARCHAR (10) DEFAULT NULL, KEY idx (c)) DEFAULT CHARSET=latin1;
INSERT INTO t VALUES (1,54,"zardosht", 'abcdefghijklmnopqrstuvwxyz', 3287);
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT a FROM t WHERE b is NULL and c is NOT NULL ORDER BY a;

Leads to:

10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

mysqld: /test/10.5_dbg/sql/handler.cc:6705: int handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed.

10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x152900305700 (LWP 502747))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x0000560391daa85a in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:424
#2  0x00005603915713a9 in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00001528fe59b8b1 in __GI_abort () at abort.c:79
#6  0x00001528fe58b42a in __assert_fail_base (fmt=0x1528fe712a38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5603920c0288 "bitmap_is_set_all(&table->s->all_set)", file=file@entry=0x5603920be322 "/test/10.5_dbg/sql/handler.cc", line=line@entry=6705, function=function@entry=0x5603920c1a40 <handler::ha_reset()::__PRETTY_FUNCTION__> "int handler::ha_reset()") at assert.c:92
#7  0x00001528fe58b4a2 in __GI___assert_fail (assertion=assertion@entry=0x5603920c0288 "bitmap_is_set_all(&table->s->all_set)", file=file@entry=0x5603920be322 "/test/10.5_dbg/sql/handler.cc", line=line@entry=6705, function=function@entry=0x5603920c1a40 <handler::ha_reset()::__PRETTY_FUNCTION__> "int handler::ha_reset()") at assert.c:101
#8  0x0000560391583eb6 in handler::ha_reset (this=0x1528dc0434a0) at /test/10.5_dbg/sql/handler.cc:6705
#9  0x0000560391237309 in close_thread_table (thd=thd@entry=0x1528dc015088, table_ptr=table_ptr@entry=0x1528dc015168) at /test/10.5_dbg/sql/sql_base.cc:968
#10 0x000056039123778a in close_thread_tables (thd=thd@entry=0x1528dc015088) at /test/10.5_dbg/sql/sql_base.cc:919
#11 0x00005603912c4417 in mysql_execute_command (thd=thd@entry=0x1528dc015088) at /test/10.5_dbg/sql/sql_parse.cc:6018
#12 0x00005603912cb324 in mysql_parse (thd=thd@entry=0x1528dc015088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x152900304350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994
#13 0x00005603912b7d54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1528dc015088, packet=packet@entry=0x1528dc067089 "", packet_length=packet_length@entry=60, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1867
#14 0x00005603912b653e in do_command (thd=0x1528dc015088) at /test/10.5_dbg/sql/sql_parse.cc:1348
#15 0x0000560391415893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1528df0d4808, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
#16 0x0000560391415fb7 in handle_one_connection (arg=arg@entry=0x1528df0d4808) at /test/10.5_dbg/sql/sql_connect.cc:1312
#17 0x00005603918805c2 in pfs_spawn_thread (arg=0x1528fd046508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
#18 0x00001528ff27e6db in start_thread (arg=0x152900305700) at pthread_create.c:463
#19 0x00001528fe67ca3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.34 (dbg), 10.3.25 (dbg), 10.4.15 (dbg), 10.5.6 (dbg), 10.6.0 (dbg)

Bug confirmed not present in:
MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (opt), 10.3.25 (opt), 10.4.15 (opt), 10.5.6 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.49 (dbg), 5.6.49 (opt), 5.7.31 (dbg), 5.7.31 (opt), 8.0.21 (dbg), 8.0.21 (opt)

Comment by Roel Van de Paar [ 2020-09-26 ]

No extra info from ASAN on testcase above.

Comment by Elena Stepanova [ 2020-10-28 ]

--source include/have_innodb.inc
 
CREATE TABLE t1 (a varchar(8), b varchar(8) as (a), key(b)) ENGINE=InnoDB;
INSERT INTO t1 (a) VALUES ('foo'), ('bar');
 
--connect(con1,localhost,root,,)
START TRANSACTION;
UPDATE t1 SET a = NULL;
 
--connection default
ANALYZE TABLE t1 PERSISTENT FOR ALL;
 
# Cleanup
--disconnect con1
DROP TABLE t1;

10.2 1ff8588c

mysqld: /data/src/10.2/sql/handler.cc:6079: int handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed.
201028  2:48:17 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fe360194f36 in __GI___assert_fail (assertion=0x5607bee33c28 "bitmap_is_set_all(&table->s->all_set)", file=0x5607bee31410 "/data/src/10.2/sql/handler.cc", line=6079, function=0x5607bee33b9a "int handler::ha_reset()") at assert.c:101
#8  0x00005607be57ebae in handler::ha_reset (this=0x7fe304037cb8) at /data/src/10.2/sql/handler.cc:6079
#9  0x00005607be278731 in close_thread_table (thd=0x7fe304000d90, table_ptr=0x7fe304000e70) at /data/src/10.2/sql/sql_base.cc:902
#10 0x00005607be2784b1 in close_thread_tables (thd=0x7fe304000d90) at /data/src/10.2/sql/sql_base.cc:859
#11 0x00005607be455b88 in mysql_admin_table (thd=0x7fe304000d90, tables=0x7fe3040127f0, check_opt=0x7fe3040058a8, operator_name=0x5607bed8a957 "analyze", lock_type=TL_READ_NO_INSERT, org_open_for_modify=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(handler * const, THD *, HA_CHECK_OPT *)) 0x5607be57a4f6 <handler::ha_analyze(THD*, st_ha_check_opt*)>, view_operator_func=0x0) at /data/src/10.2/sql/sql_admin.cc:1190
#12 0x00005607be456275 in Sql_cmd_analyze_table::execute (this=0x7fe304012e10, thd=0x7fe304000d90) at /data/src/10.2/sql/sql_admin.cc:1316
#13 0x00005607be2f5eac in mysql_execute_command (thd=0x7fe304000d90) at /data/src/10.2/sql/sql_parse.cc:5964
#14 0x00005607be2faec1 in mysql_parse (thd=0x7fe304000d90, rawbuf=0x7fe3040126f8 "ANALYZE TABLE t1 PERSISTENT FOR ALL", length=35, parser_state=0x7fe35a5fb5f0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7733
#15 0x00005607be2e925e in dispatch_command (command=COM_QUERY, thd=0x7fe304000d90, packet=0x7fe304008b51 "", packet_length=35, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1826
#16 0x00005607be2e7d59 in do_command (thd=0x7fe304000d90) at /data/src/10.2/sql/sql_parse.cc:1380
#17 0x00005607be441bb1 in do_handle_one_connection (connect=0x5607c0efb600) at /data/src/10.2/sql/sql_connect.cc:1336
#18 0x00005607be441916 in handle_one_connection (arg=0x5607c0efb600) at /data/src/10.2/sql/sql_connect.cc:1241
#19 0x00005607bec660cc in pfs_spawn_thread (arg=0x5607c0ede730) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#20 0x00007fe3606a4609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007fe360280293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

No obvious problem on a non-debug build.

Comment by Roel Van de Paar [ 2020-11-18 ]

The original testcase still produces crashes (removed red note).

CREATE TABLE t1 (a INT, b INT, c INT, v INT AS (a) VIRTUAL, INDEX(c,v)) ENGINE=InnoDB;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
INSERT INTO t1 (c) VALUES (9);
SELECT * FROM t1 WHERE c BETWEEN 1 AND 6 ORDER BY b;

Leads to:

10.5.7 e3fc9c1db04bdc5566bcdafcc3d5159199089c00(Debug)

mysqld: /test/10.5_dbg/sql/handler.cc:6707: int handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed.

10.5.7 e3fc9c1db04bdc5566bcdafcc3d5159199089c00(Debug)

Core was generated by `/test/MD211020-mariadb-10.5.7-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x15517caeb700 (LWP 3882445))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055c2c88de869 in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:424
#2  0x000055c2c8033f1f in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000155185f54859 in __GI_abort () at abort.c:79
#6  0x0000155185f54729 in __assert_fail_base (fmt=0x1551860ea588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55c2c8bd1258 "bitmap_is_set_all(&table->s->all_set)", file=0x55c2c8bce45f "/test/10.5_dbg/sql/handler.cc", line=6707, function=<optimized out>) at assert.c:92
#7  0x0000155185f65f36 in __GI___assert_fail (assertion=assertion@entry=0x55c2c8bd1258 "bitmap_is_set_all(&table->s->all_set)", file=file@entry=0x55c2c8bce45f "/test/10.5_dbg/sql/handler.cc", line=line@entry=6707, function=function@entry=0x55c2c8bcee83 "int handler::ha_reset()") at assert.c:101
#8  0x000055c2c804692e in handler::ha_reset (this=0x15512c028c40) at /test/10.5_dbg/sql/handler.cc:6707
#9  0x000055c2c7cd6b2a in close_thread_table (thd=thd@entry=0x15512c000db8, table_ptr=table_ptr@entry=0x15512c000e98) at /test/10.5_dbg/sql/sql_base.cc:968
#10 0x000055c2c7cd6fc2 in close_thread_tables (thd=thd@entry=0x15512c000db8) at /test/10.5_dbg/sql/sql_base.cc:919
#11 0x000055c2c7d770a4 in mysql_execute_command (thd=thd@entry=0x15512c000db8) at /test/10.5_dbg/sql/sql_parse.cc:6018
#12 0x000055c2c7d5ce17 in mysql_parse (thd=thd@entry=0x15512c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x15517caea3d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994
#13 0x000055c2c7d6b133 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x15512c000db8, packet=packet@entry=0x15512c008f89 "", packet_length=packet_length@entry=51, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_class.h:1254
#14 0x000055c2c7d6e85e in do_command (thd=0x15512c000db8) at /test/10.5_dbg/sql/sql_parse.cc:1348
#15 0x000055c2c7ec92c6 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55c2cbc3a7a8, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
#16 0x000055c2c7ec99cd in handle_one_connection (arg=arg@entry=0x55c2cbc3a7a8) at /test/10.5_dbg/sql/sql_connect.cc:1312
#17 0x000055c2c837ecfd in pfs_spawn_thread (arg=0x55c2cbb76178) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
#18 0x0000155186462609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#19 0x0000155186051293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.35 (dbg), 10.3.26 (dbg), 10.4.16 (dbg), 10.5.7 (dbg), 10.6.0 (dbg)

Bug confirmed not present in:
MariaDB: 10.1.48 (dbg), 10.1.48 (opt), 10.2.35 (opt), 10.3.26 (opt), 10.4.16 (opt), 10.5.7 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.50 (dbg), 5.6.50 (opt), 5.7.32 (dbg), 5.7.32 (opt), 8.0.22 (dbg), 8.0.22 (opt)

Comment by Oleksandr Byelkin [ 2021-01-07 ]

OK to push

Comment by Marko Mäkelä [ 2021-01-08 ]

nikitamalyavin, please merge this to 10.3. There are lots of conflicts.

Comment by Marko Mäkelä [ 2021-01-11 ]

Due to a large number of conflicts, I skipped this in the merge to 10.3. Please fix this in 10.3 and later branches separately.

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