[MDEV-26148] SEGV or Assertion `!page_is_comp(page) == !(index->table)->not_redundant()' Created: 2021-07-14  Updated: 2021-07-30  Resolved: 2021-07-28

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - InnoDB
Affects Version/s: 10.6.3, 10.4, 10.5, 10.6
Fix Version/s: 10.4.21, 10.5.12, 10.6.4

Type: Bug Priority: Critical
Reporter: Matthias Leich Assignee: Eugene Kosov (Inactive)
Resolution: Fixed Votes: 0
Labels: regression-10.4

Attachments: File ML_import6.test    
Issue Links:
Problem/Incident
is caused by MDEV-12026 Support encrypted SPATIAL INDEX Closed

 Description   

SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION' ;
SET DEFAULT_STORAGE_ENGINE= 'InnoDB' ;
CREATE TABLE `t1` (
`col_int` int,
`col_text` text,
`col_varchar_255` varchar(255))
ENGINE=innodb ;
INSERT INTO t1 VALUES 
(6, 'cow', 'j') ,
(NULL, 'electric', 'r') ,
(7, 'world', 'r') ,
(1, 'jail', 'functional') ,
(345178112, 'yeah', 'q') ,
(-144769024, 'hell', 'word') ,
(NULL, 'violent', 'v') ,
(3, 'surface', 'plus') ;
FLUSH TABLES t1 FOR EXPORT  ;
UNLOCK TABLES ;
CREATE TABLE imp_t1 LIKE t1  ;
ALTER TABLE imp_t1 ENGINE = InnoDB ROW_FORMAT = REDUNDANT ;
ALTER TABLE imp_t1 DISCARD TABLESPACE ;
'copy ibd file around'
ALTER TABLE imp_t1 IMPORT TABLESPACE ;
ERROR HY000: Lost connection to server during query
DROP TABLE imp_t1, t1;
ERROR HY000: Server has gone away
main.ML_import6 'innodb'                 [ fail ]
 
Build with ASAN+debug
mariadbd: /data/Server/bb-10.6-MDEV-26131/storage/innobase/btr/btr0cur.cc:683: bool btr_cur_instant_root_init(dict_index_t*, const ib_page_t*): Assertion `!page_is_comp(page) == !(index->table)->not_redundant()' failed.
210714  8:47:25 [ERROR] mysqld got signal 6 ;
??:0(__interceptor_tcgetattr)[0x7f396f524d30]
mysys/stacktrace.c:212(my_print_stacktrace)[0x55dd17d5f22e]
sql/signal_handler.cc:225(handle_fatal_signal)[0x55dd16add373]
sigaction.c:0(__restore_rt)[0x7f396f3953c0]
linux/raise.c:51(__GI_raise)[0x7f396ee8118b]
stdlib/abort.c:81(__GI_abort)[0x7f396ee60859]
intl/loadmsgcat.c:509(get_sysdep_segment_value)[0x7f396ee60729]
:0(__GI___assert_fail)[0x7f396ee71f36]
btr/btr0cur.cc:684(btr_cur_instant_root_init(dict_index_t*, unsigned char const*))[0x55dd1791d81d]
row/row0import.cc:1948(PageConverter::update_index_page(buf_block_t*))[0x55dd176f67dd]
row/row0import.cc:2082(PageConverter::update_page(buf_block_t*, unsigned short&))[0x55dd176f7580]
row/row0import.cc:2129(PageConverter::operator()(buf_block_t*))[0x55dd176e35a1]
row/row0import.cc:3599(fil_iterate(fil_iterator_t const&, buf_block_t*, AbstractCallback&))[0x55dd176eb539]
row/row0import.cc:3869(fil_tablespace_iterate(dict_table_t*, unsigned long, AbstractCallback&))[0x55dd176ed89e]
row/row0import.cc:4044(row_import_for_mysql(dict_table_t*, row_prebuilt_t*))[0x55dd176ef1df]
handler/ha_innodb.cc:13255(ha_innobase::discard_or_import_tablespace(char))[0x55dd173fbc7e]
sql/handler.cc:5147(handler::ha_discard_or_import_tablespace(char))[0x55dd16afed89]
sql/sql_table.cc:5463(mysql_discard_or_import_tablespace(THD*, TABLE_LIST*, bool))[0x55dd1657b604]
sql/sql_alter.cc:593(Sql_cmd_discard_import_tablespace::execute(THD*))[0x55dd1672832d]
sql/sql_parse.cc:5993(mysql_execute_command(THD*, bool))[0x55dd1632ed1a]
sql/sql_parse.cc:8026(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x55dd1633b1ec]
sql/sql_parse.cc:1898(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x55dd1631348b]
sql/sql_parse.cc:1404(do_command(THD*, bool))[0x55dd16310863]
sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x55dd1670e4c2]
sql/sql_connect.cc:1314(handle_one_connection)[0x55dd1670de24]
nptl/pthread_create.c:478(start_thread)[0x7f396f389609]
x86_64/clone.S:97(__GI___clone)[0x7f396ef5d293]
 
Query (0x62b0000d2238): ALTER TABLE imp_t1 IMPORT TABLESPACE
Connection ID (thread ID): 4
Status: NOT_KILLED
 
The non debug build ends up with a SEGV.
2021-07-14  8:48:09 4 [Note] InnoDB: Phase I - Update all pages
210714  8:48:09 [ERROR] mysqld got signal 11 ;
Thread 1 (Thread 0x7fd6dc4bc700 (LWP 3318159)):
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055d958d3cbaf in my_write_core (sig=sig@entry=11) at /data/Server/bb-10.6-MDEV-26131/mysys/stacktrace.c:424
#2  0x000055d9588bc220 in handle_fatal_signal (sig=11) at /data/Server/bb-10.6-MDEV-26131/sql/signal_handler.cc:344
#3  <signal handler called>
#4  rec_get_bit_field_1 (shift=0, mask=32, offs=6, rec=0x0) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/include/rem0rec.ic:568
#5  rec_get_deleted_flag (comp=0, rec=0x0) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/include/rem0rec.ic:568
#6  PageConverter::update_records (this=this@entry=0x7fd6dc4b8cd0, block=block@entry=0x7fd6a402f160) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/row/row0import.cc:1833
#7  0x000055d958bbc88a in PageConverter::update_index_page (this=this@entry=0x7fd6dc4b8cd0, block=block@entry=0x7fd6a402f160) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/include/page0page.h:263
#8  0x000055d958bbcb50 in PageConverter::update_page (this=0x7fd6dc4b8cd0, block=0x7fd6a402f160, page_type=@0x7fd6dc4b767e: 17855) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/row/row0import.cc:2082
#9  0x000055d958bba188 in PageConverter::operator() (this=0x7fd6dc4b8cd0, block=0x7fd6a402f160) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/row/row0import.cc:2129
#10 0x000055d958bb8059 in fil_iterate (callback=..., block=<optimized out>, iter=...) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/row/row0import.cc:3599
#11 fil_tablespace_iterate (table=<optimized out>, n_io_buffers=<optimized out>, callback=...) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/row/row0import.cc:3869
#12 0x000055d958587d35 in row_import_for_mysql (table=<optimized out>, prebuilt=0x7fd6a40321c8) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/row/row0import.cc:4044
#13 0x000055d958b3a356 in ha_innobase::discard_or_import_tablespace (this=0x7fd6a4031140, discard=<optimized out>) at /data/Server/bb-10.6-MDEV-26131/storage/innobase/handler/ha_innodb.cc:13255
#14 0x000055d9587441b6 in mysql_discard_or_import_tablespace (thd=thd@entry=0x7fd6a4000c58, table_list=table_list@entry=0x7fd6a4010740, discard=<optimized out>) at /data/Server/bb-10.6-MDEV-26131/sql/sql_table.cc:5463
#15 0x000055d9587b0044 in Sql_cmd_discard_import_tablespace::execute (this=0x7fd6a4010e28, thd=0x7fd6a4000c58) at /data/Server/bb-10.6-MDEV-26131/sql/sql_alter.cc:591
#16 0x000055d9586b1666 in mysql_execute_command (thd=0x7fd6a4000c58, is_called_from_prepared_stmt=<optimized out>) at /data/Server/bb-10.6-MDEV-26131/sql/sql_parse.cc:5993
#17 0x000055d9586a2486 in mysql_parse (rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>, thd=0x7fd6a4000c58) at /data/Server/bb-10.6-MDEV-26131/sql/sql_parse.cc:8026
#18 mysql_parse (thd=0x7fd6a4000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /data/Server/bb-10.6-MDEV-26131/sql/sql_parse.cc:7948
#19 0x000055d9586ade52 in dispatch_command (command=COM_QUERY, thd=0x7fd6a4000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /data/Server/bb-10.6-MDEV-26131/sql/sql_class.h:1340
#20 0x000055d9586afad8 in do_command (thd=0x7fd6a4000c58, blocking=blocking@entry=true) at /data/Server/bb-10.6-MDEV-26131/sql/sql_parse.cc:1404
#21 0x000055d9587aba27 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55d95b536028, put_in_cache=put_in_cache@entry=true) at /data/Server/bb-10.6-MDEV-26131/sql/sql_connect.cc:1410
#22 0x000055d9587abd1d in handle_one_connection (arg=0x55d95b536028) at /data/Server/bb-10.6-MDEV-26131/sql/sql_connect.cc:1312
#23 0x00007fd6de413609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#24 0x00007fd6ddfe7293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
 
origin/bb-10.6-MDEV-26131 ffc41e1cf56809f82e97daad4869fecac4b46fed 2021-07-13T23:31:16+05:30  with fix for MDEV-26131
 
origin/10.6, 10.6 315380a4d16ddb16461d906a23be341e354c30ed 2021-07-01T19:06:53+03:00



 Comments   
Comment by Marko Mäkelä [ 2021-07-15 ]

I tested this with the following:

--source include/have_innodb.inc
 
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE imp_t1 (a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
ALTER TABLE imp_t1 DISCARD TABLESPACE ;
FLUSH TABLES t1 FOR EXPORT;
let $datadir=`select @@datadir`;
--copy_file $datadir/test/t1.ibd $datadir/test/imp_t1.ibd
UNLOCK TABLES;
ALTER TABLE imp_t1 IMPORT TABLESPACE;
DROP TABLE imp_t1, t1;

Starting with 10.4, it crashes if we use innodb_checksum_algorithm=full_crc32 (which MDEV-19534 made the default in 10.5). If I explicitly specify innodb_checksum_algorithm=crc32, there is no crash:

mysqltest: At line 10: query 'ALTER TABLE imp_t1 IMPORT TABLESPACE' failed: 1808: Schema mismatch (Expected FSP_SPACE_FLAGS=0x0, .ibd file contains 0x21.)

Comment by Eugene Kosov (Inactive) [ 2021-07-23 ]

The patch is here https://github.com/MariaDB/server/commits/bb-10.4-MDEV-26148-import-redundant-crash

Comment by Marko Mäkelä [ 2021-07-26 ]

Please fix the build and regression test failures first.

Comment by Eugene Kosov (Inactive) [ 2021-07-26 ]

Regression seems fixed.

Comment by Marko Mäkelä [ 2021-07-27 ]

Please do not change the return type of page_is_comp(). It intentionally is not bool so that we can avoid a machine instruction that would ‘normalize’ the result. When normalization is needed, it can be provided by !!page_is_comp(page) == boolean_value or similar. That change also broke the Windows build, which is not happy about comparing bool with >.

The fix to FetchIndexRootPages::operator() looks OK (if you add the normalization by unary !). Thank you!

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