Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-41672

Interrupted INSERT leaves partitioned Aria table in corrupt state, leads to server crash

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
      --source include/have_sequence.inc
       
      CREATE TABLE t1 (b INT) ENGINE=Aria;
      INSERT INTO t1 VALUES (1),(2);
      CREATE TABLE t2 (a INT, b VARCHAR(64), KEY(b)) ENGINE=Aria
        PARTITION BY LIST (a) (PARTITION p0 VALUES IN (0), PARTITION p1 VALUES IN (1));
       
      # Claude says:
      # Kill a bulk INSERT..SELECT into the empty table. Aria's
      # enable_indexes() repair is aborted, the retry is aborted too, and
      # partition p0 stays "crashed and last repair failed".
      --connect (con1,localhost,root,,test)
      let $id= `SELECT CONNECTION_ID()`;
      INSERT INTO t2 VALUES (1,1);
      --send INSERT INTO t2 SELECT 0, MD5(seq) FROM seq_1_to_2000000
      --connection default
      let $wait_condition= SELECT COUNT(*) FROM information_schema.processlist WHERE info LIKE 'INSERT INTO t2 SELECT%' AND time >= 1;
      --source include/wait_condition.inc
      --replace_result $id <id>
      eval KILL QUERY $id;
      --connection con1
      --error 0,ER_QUERY_INTERRUPTED,ER_NOT_KEYFILE
      --reap
      --disconnect con1
      --connection default
      FLUSH TABLES;
       
      SELECT COUNT(*) FROM t2 PARTITION (p1);
      --error 144
      SELECT COUNT(*) FROM t2;
       
      SELECT STRAIGHT_JOIN t1.b FROM t1, t2 PARTITION (p1) WHERE LENGTH(t2.b) = t1.b;
       
      DROP TABLE t1, t2;
      

      If the test does what it is created for (which currently happens every time for me), SELECT COUNT FROM t2 already fails with the corruption error:

      main f6d172c03bf3cd71fd30ac9cc7b24fd64497b472

      SELECT COUNT(*) FROM t2;
      ERROR HY000: Got error '144 "Table is crashed and last repair failed"' for './test/t2#P#p0'
      

      It is masked in the test to proceed to the actual crash on the SELECT with JOIN:

      main f6d172c03bf3cd71fd30ac9cc7b24fd64497b472

      #4  <signal handler called>
      #5  0x000055c94438e3b6 in ha_partition::init_record_priority_queue (this=this@entry=0x625000246960) at /data/bld/main-asan-ubsan/sql/ha_partition.cc:5589
      #6  0x000055c94439277c in ha_partition::index_init (this=0x625000246960, inx=<optimized out>, sorted=<optimized out>) at /data/bld/main-asan-ubsan/sql/ha_partition.cc:5728
      #7  0x000055c9433e168a in handler::ha_index_init (this=this@entry=0x625000246960, idx=idx@entry=0, sorted=sorted@entry=true) at /data/bld/main-asan-ubsan/sql/handler.cc:4186
      #8  0x000055c9417a1470 in init_read_record_idx (info=info@entry=0x62d000113ea0, thd=<optimized out>, table=table@entry=0x619000059ba0, print_error=print_error@entry=true, idx=idx@entry=0, reverse=reverse@entry=false) at /data/bld/main-asan-ubsan/sql/records.cc:81
      #9  0x000055c9420ce274 in join_init_read_record (tab=0x62d000113dd0) at /data/bld/main-asan-ubsan/sql/sql_select.cc:26674
      #10 0x000055c9428ee305 in JOIN_TAB_SCAN::open (this=0x62d0001150e8) at /data/bld/main-asan-ubsan/sql/sql_join_cache.cc:3502
      #11 0x000055c94290ec8b in JOIN_CACHE::join_matching_records (this=0x62d000114fc0, skip_last=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_join_cache.cc:2359
      #12 0x000055c94290b7a1 in JOIN_CACHE::join_records (this=this@entry=0x62d000114fc0, skip_last=skip_last@entry=false) at /data/bld/main-asan-ubsan/sql/sql_join_cache.cc:2180
      #13 0x000055c9420778d1 in sub_select_cache (join=<optimized out>, join_tab=0x62d000113dd0, end_of_records=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:25318
      #14 0x000055c942075a9b in sub_select (join=<optimized out>, join_tab=<optimized out>, end_of_records=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:25508
      #15 0x000055c94211fc05 in do_select (join=join@entry=0x62d000110d78, procedure=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:25088
      #16 0x000055c9421fdb99 in JOIN::exec_inner (this=this@entry=0x62d000110d78) at /data/bld/main-asan-ubsan/sql/sql_select.cc:5147
      #17 0x000055c9421fe13d in JOIN::exec (this=this@entry=0x62d000110d78) at /data/bld/main-asan-ubsan/sql/sql_select.cc:4935
      #18 0x000055c9421f4ee6 in mysql_select (thd=thd@entry=0x62c0000b0220, tables=<optimized out>, fields=..., conds=conds@entry=0x62d000110078, og_num=og_num@entry=0, order=order@entry=0x0, group=<optimized out>, having=<optimized out>, proc_param=<optimized out>, select_options=<optimized out>, result=<optimized out>, unit=<optimized out>, select_lex=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:5461
      #19 0x000055c9421f602e in handle_select (thd=thd@entry=0x62c0000b0220, lex=lex@entry=0x62c0000b48d8, result=result@entry=0x62d000110d40, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/bld/main-asan-ubsan/sql/sql_select.cc:652
      #20 0x000055c941e2e10a in execute_sqlcom_select (thd=thd@entry=0x62c0000b0220, all_tables=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:6266
      #21 0x000055c941e70f8c in mysql_execute_command (thd=thd@entry=0x62c0000b0220, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:4038
      #22 0x000055c941e8f5b9 in mysql_parse (thd=thd@entry=0x62c0000b0220, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f5564cf1950) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:8005
      #23 0x000055c941e987e5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62c0000b0220, packet=packet@entry=0x629000267221 "", packet_length=packet_length@entry=78, blocking=blocking@entry=true) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:1903
      #24 0x000055c941ea4db5 in do_command (thd=thd@entry=0x62c0000b0220, blocking=blocking@entry=true) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:1437
      #25 0x000055c942775690 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x60b0000049f0, put_in_cache=put_in_cache@entry=true) at /data/bld/main-asan-ubsan/sql/sql_connect.cc:1514
      #26 0x000055c9427767f9 in handle_one_connection (arg=0x60b0000049f0) at /data/bld/main-asan-ubsan/sql/sql_connect.cc:1426
      #27 0x000055c9443fd349 in pfs_spawn_thread (arg=0x6170000070a0) at /data/bld/main-asan-ubsan/storage/perfschema/pfs.cc:2198
      #28 0x00007f55726a71f5 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #29 0x00007f55727278ec in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      UBSAN also produces a warning:

      2026-10-21 14:55:55 5 [Warning] Warning: Enabling keys got errno 188 on ./test/t2#P#p0, retrying
      2026-10-21 14:55:55 4 [ERROR] mariadbd: Got error '144 "Table is crashed and last repair failed"' for './test/t2#P#p0'
      2026-10-21 14:55:55 4 [ERROR] mariadbd: Table 't2' is marked as crashed and last (automatic?) repair failed
      /data/bld/main-asan-ubsan/sql/ha_partition.cc:5589:56: runtime error: member access within null pointer of type 'struct handler'
      261021 14:55:55 [ERROR] /share8t/bld/main-asan-ubsan/sql/mariadbd got signal 11 ;
      

      Attachments

        Activity

          People

            monty Michael Widenius
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.