[MDEV-29394] SIGSEGV in myrocks::ha_rocksdb::check_keyread_allowed on CREATE TABLE ... KEY Created: 2022-08-26  Updated: 2022-09-10  Resolved: 2022-08-27

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - RocksDB
Affects Version/s: N/A
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Roel Van de Paar Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-29393 SIGSEGV in __gnu_cxx::__atomic_add w... Closed

 Description   

Whilst this bug seems very closely related to MDEV-29393, the stack is very different, so I am creating a separate ticket for this one - in case the underlying issue is different too.
Only present in bb-10.10-MDEV-16329.

INSTALL SONAME 'ha_rocksdb.so';
CREATE TABLE t (a INT,KEY(a)) ENGINE=RocksDB;

10.10.0 7a41e4fbc62c5e917d9cb4dc045e21c983d4e73f (Optimized)

Core was generated by `/test/MDEV-16329_bb-10.10-MDEV-16329_MD240822-mariadb-10.10.0-linux-x86_64-opt/'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000014938a90dbf0 in myrocks::ha_rocksdb::check_keyread_allowed (
    this=this@entry=0x14935c2c8a00, inx=inx@entry=0, part=0, 
    all_parts=<optimized out>)
    at /test/bb-10.10-MDEV-16329_opt/storage/rocksdb/ha_rocksdb.cc:7931
7931	  res = dummy1.setup(nullptr, key_info->key_part[part].field, inx, part,
[Current thread is 1 (Thread 0x1493a4050700 (LWP 69132))]
(gdb) bt
#0  0x000014938a90dbf0 in myrocks::ha_rocksdb::check_keyread_allowed (this=this@entry=0x14935c2c8a00, inx=inx@entry=0, part=0, all_parts=<optimized out>) at /test/bb-10.10-MDEV-16329_opt/storage/rocksdb/ha_rocksdb.cc:7931
#1  0x000014938a90ddd8 in myrocks::ha_rocksdb::index_flags (this=0x14935c2c8a00, inx=0, part=<optimized out>, all_parts=<optimized out>) at /test/bb-10.10-MDEV-16329_opt/storage/rocksdb/ha_rocksdb.cc:8286
#2  0x000055dfe4ac50a1 in TABLE_SHARE::init_from_binary_frm_image (this=this@entry=0x1493a404bdb0, thd=thd@entry=0x14935c000db8, write=<optimized out>, frm_image=<optimized out>, frm_length=<optimized out>, par_image=par_image@entry=0x0, par_length=0) at /test/preview-10.10-ddl_dbg/sql/table.cc:3080
#3  0x000055dfe4c8c2b6 in ha_create_table (thd=thd@entry=0x14935c000db8, path=<optimized out>, db=0x14935c014550 "test", table_name=0x14935c013e30 "t", create_info=create_info@entry=0x1493a404d230, frm=frm@entry=0x1493a404cc60, skip_frm_file=false) at /test/preview-10.10-ddl_dbg/sql/handler.cc:5894
#4  0x000055dfe4a75a05 in create_table_impl (thd=thd@entry=0x14935c000db8, orig_db=@0x14935c013e68: {str = 0x14935c014550 "test", length = 4}, orig_table_name=@0x14935c013e78: {str = 0x14935c013e30 "t", length = 1}, db=@0x14935c013e68: {str = 0x14935c014550 "test", length = 4}, table_name=@0x14935c013e78: {str = 0x14935c013e30 "t", length = 1}, path=@0x1493a404cc50: {str = 0x1493a404cc70 "./test/t", length = 8}, options=<optimized out>, create_info=0x1493a404d230, alter_info=0x1493a404d050, create_table_mode=0, is_trans=0x1493a404cf50, key_info=0x1493a404cc48, key_count=0x1493a404cc44, frm=0x1493a404cc60) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:4929
#5  0x000055dfe4a75e4d in mysql_create_table_no_lock (thd=thd@entry=0x14935c000db8, orig_db=orig_db@entry=0x14935c013e68, orig_table_name=orig_table_name@entry=0x14935c013e78, db=0x14935c013e68, table_name=0x14935c013e78, create_info=create_info@entry=0x1493a404d230, alter_info=0x1493a404d050, is_trans=0x1493a404cf50, create_table_mode=0, table_list=0x14935c013e68, frm=0x1493a404cc60) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:5056
#6  0x000055dfe4a787b2 in mysql_create_table (alter_info=0x1493a404d050, create_info=0x1493a404d230, create_table=<optimized out>, thd=0x14935c000db8) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:5183
#7  Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x14935c000db8) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:12935
#8  0x000055dfe49a1a4d in mysql_execute_command (thd=thd@entry=0x14935c000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/preview-10.10-ddl_dbg/sql/sql_parse.cc:5996
#9  0x000055dfe498a0cd in mysql_parse (thd=thd@entry=0x14935c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1493a404f470) at /test/preview-10.10-ddl_dbg/sql/sql_parse.cc:8038
#10 0x000055dfe49976b0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14935c000db8, packet=packet@entry=0x14935c00b7f9 "CREATE TABLE t (a INT,KEY(a)) ENGINE=RocksDB", packet_length=packet_length@entry=44, blocking=blocking@entry=true) at /test/preview-10.10-ddl_dbg/sql/sql_class.h:1365
#11 0x000055dfe4999dc1 in do_command (thd=0x14935c000db8, blocking=blocking@entry=true) at /test/preview-10.10-ddl_dbg/sql/sql_parse.cc:1407
#12 0x000055dfe4afc7ba in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55dfe756b458, put_in_cache=put_in_cache@entry=true) at /test/preview-10.10-ddl_dbg/sql/sql_connect.cc:1418
#13 0x000055dfe4afccc3 in handle_one_connection (arg=0x55dfe756b458) at /test/preview-10.10-ddl_dbg/sql/sql_connect.cc:1312
#14 0x00001493bbd11609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#15 0x00001493bb8fd133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Debug can not be tested given the undefined opt_debug_sync_timeout symbol as described in MDEV-29393.



 Comments   
Comment by Roel Van de Paar [ 2022-08-26 ]

An additional slightly different stack when varying the testcase to include a partition

INSTALL SONAME 'ha_rocksdb';
CREATE TABLE t (a INT KEY,b TEXT) ENGINE=RocksDB PARTITION BY KEY(a) PARTITIONS 1;

Leads to:

10.10.0 7a41e4fbc62c5e917d9cb4dc045e21c983d4e73f (Optimized)

Core was generated by `/test/MDEV-16329_bb-10.10-MDEV-16329_MD240822-mariadb-10.10.0-linux-x86_64-opt/'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000152ea645abf0 in myrocks::ha_rocksdb::check_keyread_allowed (
    this=this@entry=0x152e20269110, inx=inx@entry=0, part=0, 
    all_parts=<optimized out>)
    at /test/bb-10.10-MDEV-16329_opt/storage/rocksdb/ha_rocksdb.cc:7931
7931	  res = dummy1.setup(nullptr, key_info->key_part[part].field, inx, part,
[Current thread is 1 (Thread 0x152ea69a9700 (LWP 1944452))]
(gdb) bt
#0  0x0000152ea645abf0 in myrocks::ha_rocksdb::check_keyread_allowed (this=this@entry=0x152e20269110, inx=inx@entry=0, part=0, all_parts=<optimized out>) at /test/bb-10.10-MDEV-16329_opt/storage/rocksdb/ha_rocksdb.cc:7931
#1  0x0000152ea645add8 in myrocks::ha_rocksdb::index_flags (this=0x152e20269110, inx=0, part=<optimized out>, all_parts=<optimized out>) at /test/bb-10.10-MDEV-16329_opt/storage/rocksdb/ha_rocksdb.cc:8286
#2  0x00005617fd9508b6 in ha_partition::index_flags (this=<optimized out>, inx=<optimized out>, part=<optimized out>, all_parts=<optimized out>) at /test/preview-10.10-ddl_dbg/sql/ha_partition.h:1307
#3  0x00005617fd4ce0a1 in TABLE_SHARE::init_from_binary_frm_image (this=this@entry=0x152ea69a4db0, thd=thd@entry=0x152e20000db8, write=<optimized out>, frm_image=<optimized out>, frm_length=<optimized out>, par_image=par_image@entry=0x0, par_length=0) at /test/preview-10.10-ddl_dbg/sql/table.cc:3080
#4  0x00005617fd6952b6 in ha_create_table (thd=thd@entry=0x152e20000db8, path=<optimized out>, db=0x152e20014598 "test", table_name=0x152e20013e78 "t", create_info=create_info@entry=0x152ea69a6230, frm=frm@entry=0x152ea69a5c60, skip_frm_file=false) at /test/preview-10.10-ddl_dbg/sql/handler.cc:5894
#5  0x00005617fd47ea05 in create_table_impl (thd=thd@entry=0x152e20000db8, orig_db=@0x152e20013eb0: {str = 0x152e20014598 "test", length = 4}, orig_table_name=@0x152e20013ec0: {str = 0x152e20013e78 "t", length = 1}, db=@0x152e20013eb0: {str = 0x152e20014598 "test", length = 4}, table_name=@0x152e20013ec0: {str = 0x152e20013e78 "t", length = 1}, path=@0x152ea69a5c50: {str = 0x152ea69a5c70 "./test/t", length = 8}, options=<optimized out>, create_info=0x152ea69a6230, alter_info=0x152ea69a6050, create_table_mode=0, is_trans=0x152ea69a5f50, key_info=0x152ea69a5c48, key_count=0x152ea69a5c44, frm=0x152ea69a5c60) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:4929
#6  0x00005617fd47ee4d in mysql_create_table_no_lock (thd=thd@entry=0x152e20000db8, orig_db=orig_db@entry=0x152e20013eb0, orig_table_name=orig_table_name@entry=0x152e20013ec0, db=0x152e20013eb0, table_name=0x152e20013ec0, create_info=create_info@entry=0x152ea69a6230, alter_info=0x152ea69a6050, is_trans=0x152ea69a5f50, create_table_mode=0, table_list=0x152e20013eb0, frm=0x152ea69a5c60) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:5056
#7  0x00005617fd4817b2 in mysql_create_table (alter_info=0x152ea69a6050, create_info=0x152ea69a6230, create_table=<optimized out>, thd=0x152e20000db8) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:5183
#8  Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x152e20000db8) at /test/preview-10.10-ddl_dbg/sql/sql_table.cc:12935
#9  0x00005617fd3aaa4d in mysql_execute_command (thd=thd@entry=0x152e20000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/preview-10.10-ddl_dbg/sql/sql_parse.cc:5996
#10 0x00005617fd3930cd in mysql_parse (thd=thd@entry=0x152e20000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x152ea69a8470) at /test/preview-10.10-ddl_dbg/sql/sql_parse.cc:8038
#11 0x00005617fd3a06b0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x152e20000db8, packet=packet@entry=0x152e2000b7f9 "CREATE TABLE t (a INT KEY,b TEXT) ENGINE=RocksDB PARTITION BY KEY(a) PARTITIONS 1", packet_length=packet_length@entry=81, blocking=blocking@entry=true) at /test/preview-10.10-ddl_dbg/sql/sql_class.h:1365
#12 0x00005617fd3a2dc1 in do_command (thd=0x152e20000db8, blocking=blocking@entry=true) at /test/preview-10.10-ddl_dbg/sql/sql_parse.cc:1407
#13 0x00005617fd5057ba in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5617ff6eb1f8, put_in_cache=put_in_cache@entry=true) at /test/preview-10.10-ddl_dbg/sql/sql_connect.cc:1418
#14 0x00005617fd505cc3 in handle_one_connection (arg=0x5617ff6eb1f8) at /test/preview-10.10-ddl_dbg/sql/sql_connect.cc:1312
#15 0x0000152ec5a5c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x0000152ec5648133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Roel Van de Paar [ 2022-08-26 ]

UniqueID's/stacks seen so far

SIGSEGV|myrocks::ha_rocksdb::check_keyread_allowed|myrocks::ha_rocksdb::index_flags|TABLE_SHARE::init_from_binary_frm_image|ha_create_table
SIGSEGV|myrocks::ha_rocksdb::check_keyread_allowed|myrocks::ha_rocksdb::index_flags|ha_partition::index_flags|TABLE_SHARE::init_from_binary_frm_image

Comment by Roel Van de Paar [ 2022-08-26 ]

Given the oddity of the errors, I decided to rebuild the branch & retest. The rebuild branch did not show the same issues, so I discarded the runs.
It looks like the 4 builds (2 branches, opt+dbg) collided (same temporary dir use during untar) with the builds of one branch being affected.
Apologies for the false alarm.

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