[MDEV-28138] MariaDB Assertion Failed in mtr_buf_t::has_space Created: 2022-03-21  Updated: 2022-04-05  Resolved: 2022-04-05

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.7, 10.8
Fix Version/s: 10.7.4, 10.8.3

Type: Bug Priority: Critical
Reporter: Jingzhou Fu Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: regression-10.7
Environment:

Linux jie-2 5.4.143-1-pve #1 SMP PVE 5.4.143-1 (Tue, 28 Sep 2021 09:10:37 +0200) x86_64 x86_64 x86_64 GNU/Linux


Issue Links:
Problem/Incident
is caused by MDEV-24621 In bulk insert, pre-sort and build in... Closed
Relates
relates to MDEV-22759 Failing assertion: !cursor->index->is... Confirmed

 Description   

PoC:

CREATE TABLE a (
  keyc SERIAL, b CHAR(255) NOT NULL DEFAULT '', c BOOLEAN DEFAULT false,
  sqlsim0 LINESTRING NOT NULL DEFAULT ST_linefromtext('linestring(448 -689)'),
  INDEX(b,c), SPATIAL INDEX `a`(sqlsim0)
) ENGINE=InnoDB;
SET unique_checks=0;
SET foreign_key_checks=0;
INSERT INTO a (keyc) VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

report:

Thread pointer: 0x62b00015e218
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 = 0x7f20978f3680 thread_stack 0x5fc00
??:0(__interceptor_backtrace)[0x7cbadb]
mysys/stacktrace.c:212(my_print_stacktrace)[0x2a86d37]
sql/signal_handler.cc:0(handle_fatal_signal)[0x15af5d9]
sigaction.c:0(__restore_rt)[0x7f20bdea23c0]
??:0(gsignal)[0x7f20bdad003b]
??:0(abort)[0x7f20bdaaf859]
ut/ut0dbg.cc:40(ut_dbg_assertion_failed(char const*, char const*, unsigned int))[0x25a393e]
include/dyn0buf.h:436(mtr_buf_t::has_space(unsigned long))[0x2405186]
row/row0ins.cc:3331(row_ins_sec_index_entry(dict_index_t*, dtuple_t*, que_thr_t*, bool))[0x2407669]
row/row0ins.cc:3704(row_ins(ins_node_t*, que_thr_t*))[0x2409c07]
:0(row_insert_for_mysql(unsigned char const*, row_prebuilt_t*, ins_mode_t))[0x24470e3]
handler/ha_innodb.cc:7800(ha_innobase::write_row(unsigned char const*))[0x2169c58]
sql/handler.cc:7522(handler::ha_write_row(unsigned char const*))[0x15ecac0]
sql/sql_insert.cc:2156(write_record(THD*, TABLE*, st_copy_info*, select_result*))[0xb72ac3]
sql/sql_insert.cc:1128(mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*))[0xb6933b]
sql/sql_parse.cc:4562(mysql_execute_command(THD*, bool))[0xc68511]
sql/sql_class.h:2734(THD::enter_stage(PSI_stage_info_v1 const*, char const*, char const*, unsigned int))[0xc4a67f]
sql/sql_parse.cc:1894(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0xc41baa]
sql/sql_parse.cc:1404(do_command(THD*, bool))[0xc4b74c]
sql/sql_connect.cc:1418(do_handle_one_connection(CONNECT*, bool))[0x111f9f3]
sql/sql_connect.cc:0(handle_one_connection)[0x111f249]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x1f3f9de]
nptl/pthread_create.c:478(start_thread)[0x7f20bde96609]
??:0(clone)[0x7f20bdbac163]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x629000087238): INSERT INTO a (keyc) VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)



 Comments   
Comment by Alice Sherepa [ 2022-03-21 ]

Thank you!
Repeatable with InnoDB on 10.7-10.8, not on 10.6 and earlier

--source include/have_innodb.inc
CREATE TABLE t1 (
  id SERIAL, 
  s LINESTRING NOT NULL DEFAULT LineFromText('LINESTRING(1 1,2 2,3 3)'),
 SPATIAL INDEX (s)
) ENGINE=InnoDB;
 
SET unique_checks=0;
SET foreign_key_checks=0;
INSERT INTO t1 (id) VALUES (0),(1),(2),(3),(4);

10.7 bf8dc0be9e4bc26a572

Version: '10.7.4-MariaDB-debug-log' 
2022-03-21 12:29:56 0x7fa52b3c4700  InnoDB: Assertion failure in file 10.7/src/storage/innobase/row/row0ins.cc line 221
InnoDB: Failing assertion: !cursor->index->is_committed()
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to https://jira.mariadb.org/
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mariadbd startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: https://mariadb.com/kb/en/library/innodb-recovery-modes/
InnoDB: about forcing recovery.
220321 12:29:56 [ERROR] mysqld got signal 6 ;
 
Server version: 10.7.4-MariaDB-debug-log
 
row/row0ins.cc:222(row_ins_sec_index_entry_by_modify(unsigned long, unsigned long, btr_cur_t*, unsigned short**, mem_block_info_t*, mem_block_info_t*, dtuple_t const*, que_thr_t*, mtr_t*))[0x563f4b5c3081]
row/row0ins.cc:3113(row_ins_sec_index_entry_low(unsigned long, unsigned long, dict_index_t*, mem_block_info_t*, mem_block_info_t*, dtuple_t*, unsigned long, que_thr_t*))[0x563f4b5d3392]
row/row0ins.cc:3327(row_ins_sec_index_entry(dict_index_t*, dtuple_t*, que_thr_t*, bool))[0x563f4b5d474c]
row/row0ins.cc:3386(row_ins_index_entry(dict_index_t*, dtuple_t*, que_thr_t*))[0x563f4b5d4c98]
row/row0ins.cc:3552(row_ins_index_entry_step(ins_node_t*, que_thr_t*))[0x563f4b5d5e15]
row/row0ins.cc:3698(row_ins(ins_node_t*, que_thr_t*))[0x563f4b5d68f0]
row/row0ins.cc:3844(row_ins_step(que_thr_t*))[0x563f4b5d7b05]
row/row0mysql.cc:1320(row_insert_for_mysql(unsigned char const*, row_prebuilt_t*, ins_mode_t))[0x563f4b621802]
handler/ha_innodb.cc:7854(ha_innobase::write_row(unsigned char const*))[0x563f4b25fd43]
sql/handler.cc:7524(handler::ha_write_row(unsigned char const*))[0x563f4a80f879]
sql/sql_insert.cc:2156(write_record(THD*, TABLE*, st_copy_info*, select_result*))[0x563f49e6da70]
sql/sql_insert.cc:1127(mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*))[0x563f49e652ca]
sql/sql_parse.cc:4562(mysql_execute_command(THD*, bool))[0x563f49f2f511]
sql/sql_parse.cc:8027(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x563f49f47c2f]
sql/sql_parse.cc:1896(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x563f49f1de66]
sql/sql_parse.cc:1402(do_command(THD*, bool))[0x563f49f1ab8a]
sql/sql_connect.cc:1418(do_handle_one_connection(CONNECT*, bool))[0x563f4a3bcb07]
sql/sql_connect.cc:1314(handle_one_connection)[0x563f4a3bc393]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x563f4b066dfc]
nptl/pthread_create.c:478(start_thread)[0x7fa53a23e609]
??:0(clone)[0x7fa539e0f163]
 
Query (0x6290001092a8): INSERT INTO t1 (id) VALUES (0),(1),(2),(3),(4)

Comment by Marko Mäkelä [ 2022-04-04 ]

Thank you, this is OK to push after addressing my coding style comments.
It could be good to add a test case as well.

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