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

Assertion `!m_prebuilt->table || table->versioned() == m_prebuilt->table->versioned()' failed in ha_innobase::open on INSERT w/ INTERVAL partitioning

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
      --source include/have_innodb.inc
       
      SET timestamp= UNIX_TIMESTAMP('2026-05-02 00:00:00');
      --error 0,ER_PARSE_ERROR,ER_PARTITIONS_MUST_BE_DEFINED_ERROR
      CREATE TABLE t1 (c DATE) ENGINE=InnoDB WITH SYSTEM VERSIONING PARTITION BY RANGE COLUMNS (c) INTERVAL 1 DAY (PARTITION p0 VALUES LESS THAN ('2026-04-20'));
      if ($mysql_errno)
      {
        --skip Needs RANGE COLUMNS ... INTERVAL partitioning
      }
      # The INSERT adds the partitions up to the current date
      INSERT INTO t1 VALUES ('2026-04-25');
      --let $v= query_get_value(SELECT COUNT(*) AS c FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' AND TABLE_TYPE='SYSTEM VERSIONED', c, 1)
      if ($v != 1)
      {
        --die The INSERT that added INTERVAL partitions removed WITH SYSTEM VERSIONING from t1
      }
      DROP TABLE t1;

      Leads to:

      CS 13.1.0 da18481158c81ca94689702073c3e04aad85a6a3 (Debug, Clang 22.1.8-20260622) Build 18/08/2026

      mariadbd: /test/13.1_dbg/storage/innobase/handler/ha_innodb.cc:6289: virtual int ha_innobase::open(const char *, int, uint): Assertion `!m_prebuilt->table || table->versioned() == m_prebuilt->table->versioned()' failed.

      CS 13.1.0 da18481158c81ca94689702073c3e04aad85a6a3 (Debug, Clang 22.1.8-20260622) Build 18/08/2026

      Core was generated by `/test/MD180826-mariadb-13.1.0-linux-x86_64-dbg/bin/mariadbd --defaults-group-su'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 1621335)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
      #3  0x00007be11ae4527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007be11ae288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007be11ae2881b in __assert_fail_base (fmt=0x7be11afd1208 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x64475e62c3e4 "!m_prebuilt->table || table->versioned() == m_prebuilt->table->versioned()", file=file@entry=0x64475e62bac1 "/test/13.1_dbg/storage/innobase/handler/ha_innodb.cc", line=line@entry=6289, function=function@entry=0x64475e62c2d0 "virtual int ha_innobase::open(const char *, int, uint)") at ./assert/assert.c:96
      #6  0x00007be11ae3b517 in __assert_fail (assertion=0x64475e62c3e4 "!m_prebuilt->table || table->versioned() == m_prebuilt->table->versioned()", file=0x64475e62bac1 "/test/13.1_dbg/storage/innobase/handler/ha_innodb.cc", line=6289, function=0x64475e62c2d0 "virtual int ha_innobase::open(const char *, int, uint)") at ./assert/assert.c:105
      #7  0x000064475dca01a5 in ha_innobase::open (this=0x73e0380dd960, name=0x7be1188dc040 "./test/t1#P#p0")at /test/13.1_dbg/storage/innobase/handler/ha_innodb.cc:6288
      #8  0x000064475d8cdf7a in handler::ha_open (this=0x73e0380dd960, table_arg=0x73e0380d4ea0, name=0x7be1188dc040 "./test/t1#P#p0", mode=2, test_if_locked=1042, mem_root=0x0, partitions_to_open=0x0)at /test/13.1_dbg/sql/handler.cc:3935
      #9  0x000064475dc2f17c in ha_partition::open_read_partitions (this=0x73e0380dcfc0, name_buff=0x7be1188dc040 "./test/t1#P#p0", name_buff_size=513) at /test/13.1_dbg/sql/ha_partition.cc:9198
      #10 0x000064475dc2e94d in ha_partition::open (this=0x73e0380dcfc0, name=0x73e0380af390 "./test/t1", mode=2, test_if_locked=18)at /test/13.1_dbg/sql/ha_partition.cc:3888
      #11 0x000064475d8cdf7a in handler::ha_open (this=0x73e0380dcfc0, table_arg=0x73e0380d4ea0, name=0x73e0380af390 "./test/t1", mode=2, test_if_locked=18, mem_root=0x0, partitions_to_open=0x0)at /test/13.1_dbg/sql/handler.cc:3935
      #12 0x000064475d6262a8 in open_table_from_share (thd=0x73e038000d60, share=0x73e0380aecd0, alias=0x73e038017190, db_stat=33, prgflag=8, ha_open_flags=18, outparam=0x73e0380d4ea0, is_create_table=false, partitions_to_open=0x0) at /test/13.1_dbg/sql/table.cc:4719
      #13 0x000064475d3ec770 in open_table (thd=0x73e038000d60, table_list=0x73e038017140, ot_ctx=0x7be1188dc918)at /test/13.1_dbg/sql/sql_base.cc:2316
      #14 0x000064475d3f1741 in open_and_process_table (thd=0x73e038000d60, tables=0x73e038017140, counter=0x7be1188dc98c, flags=0, prelocking_strategy=0x7be1188dc9f0, has_prelocking_list=false, ot_ctx=0x7be1188dc918) at /test/13.1_dbg/sql/sql_base.cc:4306
      #15 0x000064475d3f0527 in open_tables (thd=0x73e038000d60, options=@0x73e038006914: {m_options = DDL_options_st::OPT_NONE}, start=0x7be1188dc9a0, counter=0x7be1188dc98c, flags=0, prelocking_strategy=0x7be1188dc9f0) at /test/13.1_dbg/sql/sql_base.cc:4789
      #16 0x000064475d3f355a in open_and_lock_tables (thd=0x73e038000d60, options=@0x73e038006914: {m_options = DDL_options_st::OPT_NONE}, tables=0x73e038017140, derived=true, flags=0, prelocking_strategy=0x7be1188dc9f0) at /test/13.1_dbg/sql/sql_base.cc:5812
      #17 0x000064475d4017ee in open_and_lock_tables (thd=0x73e038000d60, tables=0x73e038017140, derived=true, flags=0)at /test/13.1_dbg/sql/sql_base.h:545
      #18 0x000064475d44a7da in mysql_insert (thd=0x73e038000d60, table_list=0x73e038017140, fields=@0x73e0380062d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x64475f1c59c0 <end_of_list>, last = 0x73e0380062d0, elements = 0}, <No data fields>}, values_list=@0x73e038006318: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x73e038017e90, last = 0x73e038017e90, elements = 1}, <No data fields>}, update_fields=@0x73e038006300: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x64475f1c59c0 <end_of_list>, last = 0x73e038006300, elements = 0}, <No data fields>}, update_values=@0x73e0380062e8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x64475f1c59c0 <end_of_list>, last = 0x73e0380062e8, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0)at /test/13.1_dbg/sql/sql_insert.cc:812
      #19 0x000064475d4b32f6 in mysql_execute_command (thd=0x73e038000d60, is_called_from_prepared_stmt=false) at /test/13.1_dbg/sql/sql_parse.cc:4508
      #20 0x000064475d4aa048 in mysql_parse (thd=0x73e038000d60, rawbuf=0x73e038017020 "INSERT INTO t1 VALUES ('2026-04-25')", length=36, parser_state=0x7be1188de9c0) at /test/13.1_dbg/sql/sql_parse.cc:7968
      #21 0x000064475d4a776e in dispatch_command (command=COM_QUERY, thd=0x73e038000d60, packet=0x73e0381d4971 "INSERT INTO t1 VALUES ('2026-04-25')", packet_length=36, blocking=true) at /test/13.1_dbg/sql/sql_parse.cc:1903
      #22 0x000064475d4aaaca in do_command (thd=0x73e038000d60, blocking=true)at /test/13.1_dbg/sql/sql_parse.cc:1437
      #23 0x000064475d68202e in do_handle_one_connection (connect=0x644784cbd5b0, put_in_cache=true) at /test/13.1_dbg/sql/sql_connect.cc:1514
      #24 0x000064475d681e11 in handle_one_connection (arg=0x644784ca9d60)at /test/13.1_dbg/sql/sql_connect.cc:1426
      #25 0x00007be11ae9cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #26 0x00007be11af29ecc in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

      On optimized builds, the INSERT succeeds, and t1 is no longer system-versioned:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026

      mysqltest: At line 16: The INSERT that added INTERVAL partitions removed WITH SYSTEM VERSIONING from t1

      With MyISAM, debug builds give the same result as optimized builds. Without INTERVAL, t1 stays system-versioned. The assert also happens without the SET timestamp. An UPDATE that adds the partitions gives the same assert, also on an empty table that gets its versioning from ALTER TABLE ... ADD SYSTEM VERSIONING.

      From the code it seems that range_interval_create_partitions() in sql/sql_partition_auto_interval.cc passes a new create_info to alter_add_partitions() without the versioning information. vers_create_partitions() in sql/partition_info.cc sets HA_VERSIONED_TABLE and vers_info before the same call.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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

                  Git Integration

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