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

SIGSEGV in row_merge_read_clustered_index on ALTER TABLE ... COMMENT when a partition has PAGE_COMPRESSED=1

    XMLWordPrintable

Details

    Description

      Likely cause: MDEV-40915, commit e19ed7eacbe44c6accc23febdac067b6973a4659, in CS 12.3.4. Its fix makes ha_partition::check_if_supported_inplace_alter() and ha_partition::prepare_inplace_alter_table() give InnoDB the new engine options of each partition. ha_partition::inplace_alter_table() still gives InnoDB the options of the table. CS 12.3.3, which does not have that fix, runs the testcase without a crash.

      --source include/have_partition.inc
      --source include/have_innodb.inc
      CREATE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY HASH (a) (PARTITION p0 PAGE_COMPRESSED=1);
      ALTER TABLE t1 COMMENT='x';
      DROP TABLE t1;

      Leads to:

      CS 12.3.4 9a1123dc45dde98c2e84cfa1c44dee882d0d3436 (Optimized, Clang 22.1.8-20260622) Build 16/10/2026

      Core was generated by `/test/MD161026-mariadb-12.3.4-linux-x86_64-opt/bin/mariadbd --defaults-group-su'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  row_merge_read_clustered_index (trx=0x7b374adc0b80, old_table=0x73365c24b0b8, new_table=0x73365c24b0b8, online=true, index=0x0, fts_sort_idx=0x0, psort_info=0x0, files=0x0, key_numbers=0x0, block=0x7b374a0f6000 "", tmpfd=0x7b374adba208, pct_cost=<optimized out>, crypt_block=0x0, table=<optimized out>, n_index=<optimized out>, defaults=<optimized out>, add_v=<optimized out>, col_map=<optimized out>, add_autoinc=<optimized out>, sequence=..., skip_pk_sort=<optimized out>, stage=<optimized out>, eval_table=<optimized out>, allow_not_null=<optimized out>, col_collate=<optimized out>)at /test/12.3_opt/storage/innobase/row/row0merge.cc:1929
       
      [Current thread is 1 (LWP 2950600)]
      (gdb) bt
      #0  row_merge_read_clustered_index (trx=0x7b374adc0b80, old_table=0x73365c24b0b8, new_table=0x73365c24b0b8, online=true, index=0x0, fts_sort_idx=0x0, psort_info=0x0, files=0x0, key_numbers=0x0, block=0x7b374a0f6000 "", tmpfd=0x7b374adba208, pct_cost=<optimized out>, crypt_block=0x0, table=<optimized out>, n_index=<optimized out>, defaults=<optimized out>, add_v=<optimized out>, col_map=<optimized out>, add_autoinc=<optimized out>, sequence=<optimized out>, skip_pk_sort=<optimized out>, stage=<optimized out>, eval_table=<optimized out>, allow_not_null=<optimized out>, col_collate=<optimized out>)at /test/12.3_opt/storage/innobase/row/row0merge.cc:1929
      #1  row_merge_build_indexes (trx=0x7b374adc0b80, old_table=0x73365c24b0b8, new_table=0x73365c24b0b8, online=true, indexes=0x0, key_numbers=0x0, n_indexes=0, table=0x7b374adbb300, defaults=0x0, col_map=0x0, add_autoinc=18446744073709551615, sequence=@0x73365c016150: {m_max_value = 0, m_increment = 0, m_offset = 0, m_next_value = 0, m_eof = true}, skip_pk_sort=<optimized out>, stage=0x5b9f3fa1d888, add_v=0x0, eval_table=0x7b374adbb300, allow_not_null=<optimized out>, col_collate=0x0)at /test/12.3_opt/storage/innobase/row/row0merge.cc:4824
      #2  0x00005b9f31da6ce1 in ha_innobase::inplace_alter_table (this=0x73365c157ee0, altered_table=0x7b374adbb300, ha_alter_info=0x7b374adbb160)at /test/12.3_opt/storage/innobase/handler/handler0alter.cc:8935
      #3  0x00005b9f31ceeccb in handler::ha_inplace_alter_table (this=0x7b374adba2a0, altered_table=0x7b374adbb300, ha_alter_info=0x7b374adbb160) at /test/12.3_opt/sql/handler.h:5168
      #4  ha_partition::inplace_alter_table (this=0x73365c1575d0, altered_table=0x0, ha_alter_info=0x7b374adbb160) at /test/12.3_opt/sql/ha_partition.cc:11009
      #5  0x00005b9f318e7d7e in handler::ha_inplace_alter_table (this=0x7b374adba2a0, this@entry=0x73365c000c70, altered_table=0x7b374adbb300, ha_alter_info=0x7b374adbb160)at /test/12.3_opt/sql/handler.h:5168
      #6  mysql_inplace_alter_table (thd=thd@entry=0x73365c000c70, table_list=0x73365c0136e0, table=table@entry=0x73365c23c650, altered_table=altered_table@entry=0x7b374adbb300, ha_alter_info=ha_alter_info@entry=0x7b374adbb160, target_mdl_request=<optimized out>, ddl_log_state=ddl_log_state@entry=0x7b374adbb270, trigger_param=0x7b374adbc930, alter_ctx=0x7b374adbbc08, partial_alter=@0x7b374adbb2ea: false, start_alter_id=@0x7b374adbb2a8: 0, if_exists=<optimized out>) at /test/12.3_opt/sql/sql_table.cc:8392
      #7  0x00005b9f318e3a89 in mysql_alter_table (thd=thd@entry=0x73365c000c70, new_db=new_db@entry=0x73365c005ae0, new_name=new_name@entry=0x73365c005f58, create_info=create_info@entry=0x7b374adbdca8, table_list=0x73365c0136e0, recreate_info=recreate_info@entry=0x7b374adbd3e0, alter_info=0x7b374adbdb30, order_num=0, order=0x0, ignore=<optimized out>, if_exists=<optimized out>) at /test/12.3_opt/sql/sql_table.cc:11900
      #8  0x00005b9f319592f3 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x73365c000c70) at /test/12.3_opt/sql/sql_alter.cc:705
      #9  0x00005b9f3182e800 in mysql_execute_command (thd=thd@entry=0x73365c000c70, is_called_from_prepared_stmt=false) at /test/12.3_opt/sql/sql_parse.cc:5895
      #10 0x00005b9f3182a0fd in mysql_parse (thd=thd@entry=0x73365c000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7b374adbe4f0)at /test/12.3_opt/sql/sql_parse.cc:7932
      #11 0x00005b9f318288d6 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x73365c000c70, packet=packet@entry=0x73365c008dc1 "ALTER TABLE t1 COMMENT='x'", packet_length=packet_length@entry=26, blocking=true)at /test/12.3_opt/sql/sql_parse.cc:1903
      #12 0x00005b9f3182a580 in do_command (thd=thd@entry=0x73365c000c70, blocking=true) at /test/12.3_opt/sql/sql_parse.cc:1437
      #13 0x00005b9f31952bdd in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5b9f3fa1d820, put_in_cache=true)at /test/12.3_opt/sql/sql_connect.cc:1514
      #14 0x00005b9f31952a12 in handle_one_connection (arg=arg@entry=0x5b9f3fa1d820)at /test/12.3_opt/sql/sql_connect.cc:1426
      #15 0x00005b9f31cf3cc3 in pfs_spawn_thread (arg=0x5b9f3fa4c850)at /test/12.3_opt/storage/perfschema/pfs.cc:2198
      #16 0x00007b376da9cb64 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #17 0x00007b376db29e8c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

      Debug builds crash in the same place. STATS_PERSISTENT=0, AUTO_INCREMENT=5, PAGE_COMPRESSION_LEVEL=3 or PAGE_COMPRESSED=0 in place of COMMENT='x' also crash, and so does COMMENT='x', ALGORITHM=INSTANT. A partition with ENCRYPTED=YES in place of PAGE_COMPRESSED=1 also crashes. ROW_FORMAT=DYNAMIC does not crash.

      From the code it seems that ha_innobase::prepare_inplace_alter_table() finds no change in the options of p0, so it sets up no rebuild. ha_innobase::inplace_alter_table() compares the options of the table with those of p0, finds that PAGE_COMPRESSED differs, and starts the rebuild anyway.

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Remaining Estimate - 1d
                  1d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

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