[MDEV-17070] Table corruption or Assertion `table->file->stats.records > 0 || error' or Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon actions on temporary table Created: 2018-08-25  Updated: 2019-07-06  Resolved: 2019-03-12

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Data Definition - Temporary
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.2.23, 10.3.14, 10.4.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: affects-tests

Issue Links:
Relates
relates to MDEV-18787 Temporary table marked as crashed and... Closed
relates to MDEV-19595 ER_CRASHED_ON_USAGE and Assertion `!i... Closed

 Description   

CREATE TEMPORARY TABLE t1 (f CHAR(255)) ENGINE=MyISAM;
REPLACE INTO t1 VALUES (NULL),(NULL);
ALTER TABLE t1 ADD FULLTEXT KEY(f);
--error 0,ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE t1 CHANGE IF EXISTS a b INT, ALGORITHM=INPLACE;
CHECK TABLE t1;
SELECT * INTO OUTFILE 'load_t1' FROM t1;
LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1;
 
# Cleanup
--let $datadir= `select @@datadir`
--remove_file $datadir/test/load_t1
DROP TABLE t1;

10.2 e84dc567 non-debug build

CHECK TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	check	warning	Size of datafile is: 256       Should be: 0
test.t1	check	error	Record-count is not ok; is 1   Should be: 0
test.t1	check	warning	Found 1 key parts. Should be: 0
test.t1	check	error	Corrupt

Same test case on a debug build produces the same errors on CHECK and further assertion failure:

10.2 e84dc567 debug build

mysqld: /data/src/10.2/sql/sql_select.cc:19199: int join_read_const_table(THD*, JOIN_TAB*, POSITION*): Assertion `table->file->stats.records > 0 || error' failed.
190208 13:37:42 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fc7a589fee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000562edc130a45 in join_read_const_table (thd=0x7fc784000b00, tab=0x7fc7840139d0, pos=0x7fc784013f88) at /data/src/10.2/sql/sql_select.cc:19199
#9  0x0000562edc10af8b in make_join_statistics (join=0x7fc784013150, tables_list=..., keyuse_array=0x7fc784013440) at /data/src/10.2/sql/sql_select.cc:4144
#10 0x0000562edc102382 in JOIN::optimize_inner (this=0x7fc784013150) at /data/src/10.2/sql/sql_select.cc:1582
#11 0x0000562edc100843 in JOIN::optimize (this=0x7fc784013150) at /data/src/10.2/sql/sql_select.cc:1115
#12 0x0000562edc109d54 in mysql_select (thd=0x7fc784000b00, tables=0x7fc784012a78, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fc784012678, unit=0x7fc7840046e8, select_lex=0x7fc784004e20) at /data/src/10.2/sql/sql_select.cc:3804
#13 0x0000562edc0fdff7 in handle_select (thd=0x7fc784000b00, lex=0x7fc784004620, result=0x7fc784012678, setup_tables_done_option=0) at /data/src/10.2/sql/sql_select.cc:376
#14 0x0000562edc0c94a7 in execute_sqlcom_select (thd=0x7fc784000b00, all_tables=0x7fc784012a78) at /data/src/10.2/sql/sql_parse.cc:6484
#15 0x0000562edc0bf428 in mysql_execute_command (thd=0x7fc784000b00) at /data/src/10.2/sql/sql_parse.cc:3490
#16 0x0000562edc0cd381 in mysql_parse (thd=0x7fc784000b00, rawbuf=0x7fc784012458 "SELECT * INTO OUTFILE 'load_t1' FROM t1", length=39, parser_state=0x7fc7a037c200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8018
#17 0x0000562edc0bacbb in dispatch_command (command=COM_QUERY, thd=0x7fc784000b00, packet=0x7fc78408d761 "SELECT * INTO OUTFILE 'load_t1' FROM t1", packet_length=39, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1829
#18 0x0000562edc0b95c6 in do_command (thd=0x7fc784000b00) at /data/src/10.2/sql/sql_parse.cc:1379
#19 0x0000562edc20ca6e in do_handle_one_connection (connect=0x562edf9df690) at /data/src/10.2/sql/sql_connect.cc:1336
#20 0x0000562edc20c7fb in handle_one_connection (arg=0x562edf9df690) at /data/src/10.2/sql/sql_connect.cc:1242
#21 0x0000562edc633f3e in pfs_spawn_thread (arg=0x562edf942e00) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#22 0x00007fc7a7576494 in start_thread (arg=0x7fc7a037d700) at pthread_create.c:333
#23 0x00007fc7a595c93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Same test case on a debug build without CHECK produces a different assertion failure:

Test case without CHECK

CREATE TEMPORARY TABLE t1 (f CHAR(255)) ENGINE=MyISAM;
REPLACE INTO t1 VALUES (NULL),(NULL);
ALTER TABLE t1 ADD FULLTEXT KEY(f);
--error 0,ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE t1 CHANGE IF EXISTS a b INT, ALGORITHM=INPLACE;
SELECT * INTO OUTFILE 'load_t1' FROM t1;
LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1;
 
# Cleanup
--let $datadir= `select @@datadir`
--remove_file $datadir/test/load_t1
DROP TABLE t1;

10.2 e84dc567 debug build

mysqld: /data/src/10.2/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
190208 13:40:27 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f50c0476ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000558448335583 in Diagnostics_area::set_ok_status (this=0x7f50a8005ca0, affected_rows=0, last_insert_id=0, message=0x7f50ba751130 "Records: 0  Deleted: 0  Skipped: 0  Warnings: 1") at /data/src/10.2/sql/sql_error.cc:380
#9  0x00005584482e7ba5 in my_ok (thd=0x7f50a8000b00, affected_rows=0, id=0, message=0x7f50ba751130 "Records: 0  Deleted: 0  Skipped: 0  Warnings: 1") at /data/src/10.2/sql/sql_class.h:4509
#10 0x0000558448785b27 in mysql_load (thd=0x7f50a8000b00, ex=0x7f50a8012538, table_list=0x7f50a80125c0, fields_vars=..., set_fields=..., set_values=..., handle_duplicates=DUP_REPLACE, ignore=false, read_file_from_client=false) at /data/src/10.2/sql/sql_load.cc:782
#11 0x0000558448366622 in mysql_execute_command (thd=0x7f50a8000b00) at /data/src/10.2/sql/sql_parse.cc:4839
#12 0x0000558448370381 in mysql_parse (thd=0x7f50a8000b00, rawbuf=0x7f50a8012458 "LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1", length=48, parser_state=0x7f50ba752200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8018
#13 0x000055844835dcbb in dispatch_command (command=COM_QUERY, thd=0x7f50a8000b00, packet=0x7f50a808d761 "", packet_length=48, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1829
#14 0x000055844835c5c6 in do_command (thd=0x7f50a8000b00) at /data/src/10.2/sql/sql_parse.cc:1379
#15 0x00005584484afa6e in do_handle_one_connection (connect=0x55844ab88690) at /data/src/10.2/sql/sql_connect.cc:1336
#16 0x00005584484af7fb in handle_one_connection (arg=0x55844ab88690) at /data/src/10.2/sql/sql_connect.cc:1242
#17 0x00005584488d6f3e in pfs_spawn_thread (arg=0x55844aaebe00) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#18 0x00007f50c214d494 in start_thread (arg=0x7f50ba753700) at pthread_create.c:333
#19 0x00007f50c053393f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Not reproducible on 10.1, although it produces bytes lost warnings

Warning: 65496 bytes lost at 0x7f1374215070, allocated by T@0 at mysys/my_alloc.c:242, myisam/ft_parser.c:54, myisam/ft_update.c:129, myisam/ft_update.c:251, myisam/mi_write.c:115, myisam/ha_myisam.cc:896, sql/handler.cc:5940, sql/sql_insert.cc:1644

Not reproducible with Aria.
Not applicable to InnoDB, as it doesn't allow created an FT index on a temporary table.


LATER UPDATE

Here is another test case, without fulltext, with Aria. Same testcase pattern, same affected versions, also assertion failure or table corruption, so I assume it's the same problem.

CREATE TABLE t (x INT) ENGINE=Aria;
CREATE TEMPORARY TABLE t (i INT) ENGINE=Aria;
INSERT INTO t VALUES (1) ;
--error 0,ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE t CHANGE COLUMN IF EXISTS a b INT, ALGORITHM=INPLACE;
ALTER TABLE t;
 
# Cleanup
DROP TEMPORARY TABLE t;
DROP TABLE t;

10.2 945c748a debug

2019-02-22 16:55:18 140315403147008 [ERROR] mysqld: Table '/data/bld/10.2/mysql-test/var/tmp/mysqld.1/#sql2719_4_0' is marked as crashed and should be repaired
2019-02-22 16:55:18 140315403147008 [ERROR] mysqld: Table 't' is marked as crashed and should be repaired
mysqld: /data/src/10.2/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
190222 16:55:18 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f9dbf950ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000560c83b6e573 in Diagnostics_area::set_ok_status (this=0x7f9da8005ca0, affected_rows=0, last_insert_id=0, message=0x7f9db9c2a280 "Records: 0  Duplicates: 0  Warnings: 2") at /data/src/10.2/sql/sql_error.cc:380
#9  0x0000560c83b20b95 in my_ok (thd=0x7f9da8000b00, affected_rows=0, id=0, message=0x7f9db9c2a280 "Records: 0  Duplicates: 0  Warnings: 2") at /data/src/10.2/sql/sql_class.h:4509
#10 0x0000560c83c719ea in mysql_alter_table (thd=0x7f9da8000b00, new_db=0x7f9da8012b30 "test", new_name=0x0, create_info=0x7f9db9c2ae50, table_list=0x7f9da8012520, alter_info=0x7f9db9c2ada0, order_num=0, order=0x0, ignore=false) at /data/src/10.2/sql/sql_table.cc:9052
#11 0x0000560c83ceddc7 in Sql_cmd_alter_table::execute (this=0x7f9da8012b38, thd=0x7f9da8000b00) at /data/src/10.2/sql/sql_alter.cc:329
#12 0x0000560c83ba4510 in mysql_execute_command (thd=0x7f9da8000b00) at /data/src/10.2/sql/sql_parse.cc:6231
#13 0x0000560c83ba9371 in mysql_parse (thd=0x7f9da8000b00, rawbuf=0x7f9da8012458 "ALTER TABLE t", length=13, parser_state=0x7f9db9c2c200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8018
#14 0x0000560c83b96cab in dispatch_command (command=COM_QUERY, thd=0x7f9da8000b00, packet=0x7f9da808d3b1 "ALTER TABLE t", packet_length=13, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1829
#15 0x0000560c83b955b6 in do_command (thd=0x7f9da8000b00) at /data/src/10.2/sql/sql_parse.cc:1379
#16 0x0000560c83ce8a5e in do_handle_one_connection (connect=0x560c86be2690) at /data/src/10.2/sql/sql_connect.cc:1336
#17 0x0000560c83ce87eb in handle_one_connection (arg=0x560c86be2690) at /data/src/10.2/sql/sql_connect.cc:1242
#18 0x0000560c8410ff2e in pfs_spawn_thread (arg=0x560c86b45e00) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#19 0x00007f9dc1627494 in start_thread (arg=0x7f9db9c2d700) at pthread_create.c:333
#20 0x00007f9dbfa0d93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Non-debug doesn't crash, but the corruption is still there:

10.2 non-debug 945c748a

mysqltest: At line 6: query 'ALTER TABLE t' failed: 145: Table '/data/bld/10.2-rel/mysql-test/var/tmp/mysqld.1/#sql2816_4_0' is marked as crashed and should be repaired



 Comments   
Comment by Elena Stepanova [ 2019-03-06 ]

Raised priority due to the variation without FULLTEXT, only ordinary operations.

Comment by Elena Stepanova [ 2019-03-10 ]

More variations of test cases and stack traces.

CREATE TEMPORARY TABLE t1 (a INT) ENGINE=Aria;
INSERT INTO t1 VALUES (1),(2);
CREATE OR REPLACE TABLE t1 (b INT);
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1 CHANGE COLUMN IF EXISTS c c VARBINARY(8), ADD KEY (d);
SHOW CREATE TABLE t1;
 
# Cleanup
DROP TEMPORARY TABLE t1;
DROP TABLE t1;

10.2 ab7e2b04

mysqld: /data/src/10.2/sql/sql_error.cc:420: void Diagnostics_area::set_eof_status(THD*): Assertion `! is_set()' failed.
190310 14:54:48 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f4693e58ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055a08650e4e5 in Diagnostics_area::set_eof_status (this=0x7f467c005cb0, thd=0x7f467c000b00) at /data/src/10.2/sql/sql_error.cc:420
#9  0x000055a086477da8 in my_eof (thd=0x7f467c000b00) at /data/src/10.2/sql/sql_class.h:4529
#10 0x000055a0865cdaf1 in mysqld_show_create (thd=0x7f467c000b00, table_list=0x7f467c012540) at /data/src/10.2/sql/sql_show.cc:1362
#11 0x000055a08653d386 in mysql_execute_command (thd=0x7f467c000b00) at /data/src/10.2/sql/sql_parse.cc:4289
#12 0x000055a08654923b in mysql_parse (thd=0x7f467c000b00, rawbuf=0x7f467c012468 "SHOW CREATE TABLE t1", length=20, parser_state=0x7f468e134200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8059
#13 0x000055a086536ad1 in dispatch_command (command=COM_QUERY, thd=0x7f467c000b00, packet=0x7f467c08d771 "", packet_length=20, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1829
#14 0x000055a0865353ee in do_command (thd=0x7f467c000b00) at /data/src/10.2/sql/sql_parse.cc:1379
#15 0x000055a086688a16 in do_handle_one_connection (connect=0x55a08a399b30) at /data/src/10.2/sql/sql_connect.cc:1336
#16 0x000055a0866887a3 in handle_one_connection (arg=0x55a08a399b30) at /data/src/10.2/sql/sql_connect.cc:1242
#17 0x000055a086ab08b4 in pfs_spawn_thread (arg=0x55a08a2fd890) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#18 0x00007f4695b2f494 in start_thread (arg=0x7f468e135700) at pthread_create.c:333
#19 0x00007f4693f1593f in clone () from /lib/x86_64-linux-gnu/libc.so.6

CREATE TEMPORARY TABLE t1 (a INT) ENGINE=Aria;
INSERT INTO t1 VALUES (1),(2);
CREATE OR REPLACE TABLE t1 (b INT);
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1 CHANGE COLUMN IF EXISTS c c VARBINARY(8), ADD KEY (d);
TRUNCATE TABLE t1;
 
# Cleanup
DROP TEMPORARY TABLE t1;
DROP TABLE t1;

10.2 ab7e2b04

mysqld: /data/src/10.2/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
190310 14:56:02 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fbc89811ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000558d1175233d in Diagnostics_area::set_ok_status (this=0x7fbc68005cb0, affected_rows=0, last_insert_id=0, message=0x0) at /data/src/10.2/sql/sql_error.cc:380
#9  0x0000558d11704981 in my_ok (thd=0x7fbc68000b00, affected_rows=0, id=0, message=0x0) at /data/src/10.2/sql/sql_class.h:4519
#10 0x0000558d11bcebef in Sql_cmd_truncate_table::execute (this=0x7fbc68012b50, thd=0x7fbc68000b00) at /data/src/10.2/sql/sql_truncate.cc:500
#11 0x0000558d117883d9 in mysql_execute_command (thd=0x7fbc68000b00) at /data/src/10.2/sql/sql_parse.cc:6272
#12 0x0000558d1178d23b in mysql_parse (thd=0x7fbc68000b00, rawbuf=0x7fbc68012468 "TRUNCATE TABLE t1", length=17, parser_state=0x7fbc842ee200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8059
#13 0x0000558d1177aad1 in dispatch_command (command=COM_QUERY, thd=0x7fbc68000b00, packet=0x7fbc6808d771 "TRUNCATE TABLE t1", packet_length=17, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1829
#14 0x0000558d117793ee in do_command (thd=0x7fbc68000b00) at /data/src/10.2/sql/sql_parse.cc:1379
#15 0x0000558d118cca16 in do_handle_one_connection (connect=0x558d14d42b30) at /data/src/10.2/sql/sql_connect.cc:1336
#16 0x0000558d118cc7a3 in handle_one_connection (arg=0x558d14d42b30) at /data/src/10.2/sql/sql_connect.cc:1242
#17 0x0000558d11cf48b4 in pfs_spawn_thread (arg=0x558d14ca6890) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#18 0x00007fbc8b4e8494 in start_thread (arg=0x7fbc842ef700) at pthread_create.c:333
#19 0x00007fbc898ce93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

CREATE TEMPORARY TABLE t1 (a INT) ENGINE=Aria;
INSERT INTO t1 VALUES (1),(2);
CREATE OR REPLACE TABLE t1 (b INT);
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1 CHANGE COLUMN IF EXISTS c c VARBINARY(8), ADD KEY (d);
DROP TABLE t1;
 
# Cleanup
DROP TEMPORARY TABLE t1;
DROP TABLE t1;

mysqld: /data/src/10.2/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
190310 15:27:51 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f7661ceaee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00005617f49cb33d in Diagnostics_area::set_ok_status (this=0x7f7640005cb0, affected_rows=0, last_insert_id=0, message=0x0) at /data/src/10.2/sql/sql_error.cc:380
#9  0x00005617f497d981 in my_ok (thd=0x7f7640000b00, affected_rows=0, id=0, message=0x0) at /data/src/10.2/sql/sql_class.h:4519
#10 0x00005617f4abbabb in mysql_rm_table (thd=0x7f7640000b00, tables=0x7f7640012530, if_exists=0 '\000', drop_temporary=0 '\000') at /data/src/10.2/sql/sql_table.cc:2088
#11 0x00005617f49fc100 in mysql_execute_command (thd=0x7f7640000b00) at /data/src/10.2/sql/sql_parse.cc:4806
#12 0x00005617f4a0623b in mysql_parse (thd=0x7f7640000b00, rawbuf=0x7f7640012468 "DROP TABLE t1", length=13, parser_state=0x7f764ffb4200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8059
#13 0x00005617f49f3ad1 in dispatch_command (command=COM_QUERY, thd=0x7f7640000b00, packet=0x7f764008d821 "DROP TABLE t1", packet_length=13, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1829
#14 0x00005617f49f23ee in do_command (thd=0x7f7640000b00) at /data/src/10.2/sql/sql_parse.cc:1379
#15 0x00005617f4b45a16 in do_handle_one_connection (connect=0x5617f6cedb30) at /data/src/10.2/sql/sql_connect.cc:1336
#16 0x00005617f4b457a3 in handle_one_connection (arg=0x5617f6cedb30) at /data/src/10.2/sql/sql_connect.cc:1242
#17 0x00005617f4f6d8b4 in pfs_spawn_thread (arg=0x5617f6c51890) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#18 0x00007f76639c1494 in start_thread (arg=0x7f764ffb5700) at pthread_create.c:333
#19 0x00007f7661da793f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Comment by Sergey Vojtovich [ 2019-03-11 ]

ok to push

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