[MDEV-14943] Assertion `block->type == PAGECACHE_EMPTY_PAGE || block->type == type || type == PAGECACHE_LSN_PAGE || type == PAGECACHE_READ_UNKNOWN_PAGE || block->type == PAGECACHE_READ_UNKNOWN_PAGE' failed in pagecache_read upon CREATE ... SELECT from Aria table Created: 2018-01-14  Updated: 2018-09-27  Resolved: 2018-05-15

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Aria
Affects Version/s: 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.0.36, 10.1.34, 10.2.15, 10.3.7

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: None

Attachments: HTML File threads    

 Description   

Note: the test case is suspiciously similar to MDEV-15878, although the assertion failure, stack trace and non-debug results are different.

CREATE TABLE t1 (f INT) ENGINE=Aria;
INSERT INTO t1 VALUES (1),(2);
--error ER_BAD_FIELD_ERROR
ALTER TABLE t1 ORDER BY unknown_column;
CREATE TABLE t2 SELECT * FROM t1;
 
# Cleanup
DROP TABLE t1, t2;

10.0 400a8eb60f83

mysqld: /data/src/10.0/storage/maria/ma_pagecache.c:3426: pagecache_read: Assertion `block->type == PAGECACHE_EMPTY_PAGE || block->type == type || type == PAGECACHE_LSN_PAGE || type == PAGECACHE_READ_UNKNOWN_PAGE || block->type == PAGECACHE_READ_UNKNOWN_PAGE' failed.
180416 14:20:35 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f304e33fee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000000000a12f23 in pagecache_read (pagecache=0x202ffc0 <maria_pagecache_var>, file=0x7f3046b5c4a0, pageno=1, level=0, buff=0x7f304694a070 '\245' <repeats 200 times>..., type=PAGECACHE_PLAIN_PAGE, lock=PAGECACHE_LOCK_LEFT_UNLOCKED, page_link=0x7f305040e5f8) at /data/src/10.0/storage/maria/ma_pagecache.c:3422
#9  0x0000000000a4e4cc in _ma_scan_block_record (info=0x7f3046b5c070, record=0x7f3046827a88 "\377", record_pos=0, skip_deleted=1 '\001') at /data/src/10.0/storage/maria/ma_blockrec.c:5462
#10 0x0000000000a3c4a5 in maria_scan (info=0x7f3046b5c070, record=0x7f3046827a88 "\377") at /data/src/10.0/storage/maria/ma_scan.c:54
#11 0x00000000009ed794 in ha_maria::rnd_next (this=0x7f304687d888, buf=0x7f3046827a88 "\377") at /data/src/10.0/storage/maria/ha_maria.cc:2459
#12 0x000000000083f7be in handler::ha_rnd_next (this=0x7f304687d888, buf=0x7f3046827a88 "\377") at /data/src/10.0/sql/handler.cc:2625
#13 0x00000000009701f9 in rr_sequential (info=0x7f304694dc28) at /data/src/10.0/sql/records.cc:470
#14 0x00000000006af8cd in join_init_read_record (tab=0x7f304694db80) at /data/src/10.0/sql/sql_select.cc:18877
#15 0x00000000006ad7eb in sub_select (join=0x7f30468fb148, join_tab=0x7f304694db80, end_of_records=false) at /data/src/10.0/sql/sql_select.cc:17971
#16 0x00000000006ad0c0 in do_select (join=0x7f30468fb148, fields=0x7f30482a6210, table=0x0, procedure=0x0) at /data/src/10.0/sql/sql_select.cc:17636
#17 0x0000000000689e4b in JOIN::exec_inner (this=0x7f30468fb148) at /data/src/10.0/sql/sql_select.cc:3108
#18 0x0000000000687308 in JOIN::exec (this=0x7f30468fb148) at /data/src/10.0/sql/sql_select.cc:2394
#19 0x000000000068a6aa in mysql_select (thd=0x7f30482a2070, rref_pointer_array=0x7f30482a63a0, tables=0x7f30468fa8b0, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x7f30468fb068, unit=0x7f30482a5a08, select_lex=0x7f30482a60f8) at /data/src/10.0/sql/sql_select.cc:3333
#20 0x0000000000680908 in handle_select (thd=0x7f30482a2070, lex=0x7f30482a5940, result=0x7f30468fb068, setup_tables_done_option=0) at /data/src/10.0/sql/sql_select.cc:377
#21 0x000000000064e6c7 in mysql_execute_command (thd=0x7f30482a2070) at /data/src/10.0/sql/sql_parse.cc:3008
#22 0x0000000000657d16 in mysql_parse (thd=0x7f30482a2070, rawbuf=0x7f30468fa088 "CREATE TABLE t2 SELECT * FROM t1", length=32, parser_state=0x7f305040f640) at /data/src/10.0/sql/sql_parse.cc:6569
#23 0x000000000064a855 in dispatch_command (command=COM_QUERY, thd=0x7f30482a2070, packet=0x7f30497e5071 "CREATE TABLE t2 SELECT * FROM t1", packet_length=32) at /data/src/10.0/sql/sql_parse.cc:1296
#24 0x0000000000649b55 in do_command (thd=0x7f30482a2070) at /data/src/10.0/sql/sql_parse.cc:999
#25 0x0000000000769e24 in do_handle_one_connection (thd_arg=0x7f30482a2070) at /data/src/10.0/sql/sql_connect.cc:1377
#26 0x0000000000769b96 in handle_one_connection (arg=0x7f30482a2070) at /data/src/10.0/sql/sql_connect.cc:1292
#27 0x0000000000aca772 in pfs_spawn_thread (arg=0x7f30481a2370) at /data/src/10.0/storage/perfschema/pfs.cc:1861
#28 0x00007f3050043494 in start_thread (arg=0x7f3050410700) at pthread_create.c:333
#29 0x00007f304e3fc93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Reproducible on 10.0-10.3. Not reproducible on 5.5.
No visible effect on a non-debug build.



 Comments   
Comment by Elena Stepanova [ 2018-04-02 ]

Occurrence on bb-10.2-compatibility: https://api.travis-ci.org/v3/job/360334979/log.txt

Comment by Michael Widenius [ 2018-05-15 ]

Problem was that if copy_data_between_tables() didn't do proper
clean up in case of failures:

  • copy object was not properly freed
  • end_bulk_insert() was not called
  • mysql_trans_prepare_alter_copy_data() set THD->transaction.on to
    false which was not properly restored

The last part caused a crash in Aria as Aria depends on that THD
is correct.

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