Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. 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

    XMLWordPrintable

    Details

      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
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serg Sergei Golubchik
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: