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

Non-debug assertion failure in btr_pcur_t::restore_position upon HANDLER operations

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
      --source include/have_innodb.inc
       
      CREATE TABLE t (id INT PRIMARY KEY, a BLOB) ENGINE=InnoDB PARTITION BY KEY(id);
      INSERT INTO t (id) VALUES (1),(2);
       
      HANDLER t OPEN;
      HANDLER t READ `PRIMARY` = (1);
      HANDLER t READ `PRIMARY` NEXT;
       
      HANDLER t CLOSE;
      DROP TABLE t;
      

      12.2 de72d02bffe6639ef0b7911966a3f85e3eba052f

      2026-02-10 14:32:06 0x7f3c5d8bc6c0  InnoDB: Assertion failure in file /data/bld/12.2-asan-ubsan/storage/innobase/btr/btr0pcur.cc line 335
      InnoDB: Failing assertion: old_rec
       
      #9  0x0000559fd767af3f in ut_dbg_assertion_failed (expr=expr@entry=0x559fd8b994c0 "old_rec", file=file@entry=0x559fd8b96f80 "/data/bld/12.2-asan-ubsan/storage/innobase/btr/btr0pcur.cc", line=line@entry=335) at /data/bld/12.2-asan-ubsan/storage/innobase/ut/ut0dbg.cc:60
      #10 0x0000559fd773a0db in btr_pcur_t::restore_position (this=this@entry=0x6200000102f8, restore_latch_mode=restore_latch_mode@entry=BTR_SEARCH_LEAF, mtr=mtr@entry=0x7f3c5d8b8870) at /data/bld/12.2-asan-ubsan/storage/innobase/btr/btr0pcur.cc:335
      #11 0x0000559fd74c6843 in sel_restore_position_for_mysql (same_user_rec=same_user_rec@entry=0x7f3c5d8b7a80, latch_mode=latch_mode@entry=BTR_SEARCH_LEAF, pcur=pcur@entry=0x6200000102f8, moves_up=moves_up@entry=true, mtr=mtr@entry=0x7f3c5d8b8870) at /data/bld/12.2-asan-ubsan/storage/innobase/row/row0sel.cc:3651
      #12 0x0000559fd74e8eb0 in row_search_mvcc (buf=buf@entry=0x62500029cab8 "\377\001", mode=PAGE_CUR_GE, mode@entry=PAGE_CUR_UNSUPP, prebuilt=0x620000010118, match_mode=match_mode@entry=0, direction=direction@entry=1) at /data/bld/12.2-asan-ubsan/storage/innobase/row/row0sel.cc:4740
      #13 0x0000559fd6e6bbcd in ha_innobase::general_fetch (this=this@entry=0x62500029c250, buf=buf@entry=0x62500029cab8 "\377\001", direction=direction@entry=1, match_mode=match_mode@entry=0) at /data/bld/12.2-asan-ubsan/storage/innobase/handler/ha_innodb.cc:9232
      #14 0x0000559fd6e6cb13 in ha_innobase::index_next (this=0x62500029c250, buf=0x62500029cab8 "\377\001") at /data/bld/12.2-asan-ubsan/storage/innobase/handler/ha_innodb.cc:9287
      #15 0x0000559fd5a30240 in handler::ha_index_next (this=this@entry=0x62500029c250, buf=buf@entry=0x62500029cab8 "\377\001") at /data/bld/12.2-asan-ubsan/sql/handler.cc:3961
      #16 0x0000559fd6a0b45e in ha_partition::handle_unordered_next (this=this@entry=0x62500029b948, buf=buf@entry=0x62500029cab8 "\377\001", is_next_same=is_next_same@entry=false) at /data/bld/12.2-asan-ubsan/sql/ha_partition.cc:7825
      #17 0x0000559fd6a428b0 in ha_partition::index_next (this=0x62500029b948, buf=<optimized out>) at /data/bld/12.2-asan-ubsan/sql/ha_partition.cc:6289
      #18 0x0000559fd5a2fa23 in handler::ha_index_next (this=this@entry=0x62500029b948, buf=<optimized out>) at /data/bld/12.2-asan-ubsan/sql/handler.cc:3961
      #19 0x0000559fd4373b18 in mysql_ha_read (thd=thd@entry=0x62c0001e0218, tables=tables@entry=0x62d0001725d8, mode=mode@entry=RNEXT, keyname=keyname@entry=0x62d000172d30 "PRIMARY", key_expr=key_expr@entry=0x62d000172d50, ha_rkey_mode=ha_rkey_mode@entry=HA_READ_KEY_EXACT, cond=<optimized out>, select_limit_cnt=<optimized out>, offset_limit_cnt=<optimized out>) at /data/bld/12.2-asan-ubsan/sql/sql_handler.cc:903
      #20 0x0000559fd45adfdf in mysql_execute_command (thd=thd@entry=0x62c0001e0218, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:5500
      #21 0x0000559fd45b84e8 in mysql_parse (thd=thd@entry=0x62c0001e0218, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f3c5d8baa10) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:7932
      #22 0x0000559fd45c15fe in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62c0001e0218, packet=packet@entry=0x6290002d0219 "", packet_length=packet_length@entry=29, blocking=blocking@entry=true) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:1896
      #23 0x0000559fd45ce5b2 in do_command (thd=thd@entry=0x62c0001e0218, blocking=blocking@entry=true) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:1432
      #24 0x0000559fd4e24f50 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x6080000079b8, put_in_cache=put_in_cache@entry=true) at /data/bld/12.2-asan-ubsan/sql/sql_connect.cc:1503
      #25 0x0000559fd4e260b9 in handle_one_connection (arg=0x6080000079b8) at /data/bld/12.2-asan-ubsan/sql/sql_connect.cc:1415
      #26 0x0000559fd6a611a7 in pfs_spawn_thread (arg=0x617000008598) at /data/bld/12.2-asan-ubsan/storage/perfschema/pfs.cc:2198
      #27 0x00007f3c6e2a81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #28 0x00007f3c6e32885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Debug and non-debug builds fail the same way.

      The failure started happening after this commit in 12.2.2:

      commit d640758b9478f4da9ac0023b1ac389ffc23aa9bb
      Commit:     Sergei Golubchik
      CommitDate: Fri Jan 23 17:00:05 2026 +0100
       
          MDEV-37832 The IF operator implicitly sets SHARED LOCK
      

      Another (this time a debug) assertion failure:

      --source include/have_partition.inc
       
      CREATE TABLE t (pk TINYINT PRIMARY KEY) PARTITION BY KEY (pk) PARTITIONS 2;
      INSERT INTO t VALUES (1),(2);
      SELECT * FROM t WHERE pk = 256;
      HANDLER t OPEN;
      HANDLER t READ `PRIMARY` NEXT;
      HANDLER t READ `PRIMARY` NEXT;
       
      HANDLER t CLOSE;
      DROP TABLE t;
      

      12.2 de72d02bffe6639ef0b7911966a3f85e3eba052f

      mariadbd: /data/bld/12.2-asan-ubsan/sql/ha_partition.cc:7787: int ha_partition::handle_unordered_next(uchar*, bool): Assertion `0' failed.
      260210 19:24:45 [ERROR] /share8t/bld/12.2-asan-ubsan/sql/mariadbd got signal 6 ;
       
      #9  0x00007f2a30a45395 in __assert_fail_base (fmt=0x7f2a30bb9a90 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55d566546d00 "0", file=file@entry=0x55d566546620 "/data/bld/12.2-asan-ubsan/sql/ha_partition.cc", line=line@entry=7787, function=function@entry=0x55d56654ed20 "int ha_partition::handle_unordered_next(uchar*, bool)") at ./assert/assert.c:92
      #10 0x00007f2a30a53eb2 in __GI___assert_fail (assertion=0x55d566546d00 "0", file=0x55d566546620 "/data/bld/12.2-asan-ubsan/sql/ha_partition.cc", line=7787, function=0x55d56654ed20 "int ha_partition::handle_unordered_next(uchar*, bool)") at ./assert/assert.c:101
      #11 0x000055d5646bab53 in ha_partition::handle_unordered_next (this=this@entry=0x62500025a948, buf=buf@entry=0x62500025c308 "\377", is_next_same=is_next_same@entry=false) at /data/bld/12.2-asan-ubsan/sql/ha_partition.cc:7787
      #12 0x000055d5646f28b0 in ha_partition::index_next (this=0x62500025a948, buf=<optimized out>) at /data/bld/12.2-asan-ubsan/sql/ha_partition.cc:6289
      #13 0x000055d5636dfa23 in handler::ha_index_next (this=this@entry=0x62500025a948, buf=<optimized out>) at /data/bld/12.2-asan-ubsan/sql/handler.cc:3961
      #14 0x000055d562023b18 in mysql_ha_read (thd=thd@entry=0x62c0000c0218, tables=tables@entry=0x62d0000f05d8, mode=mode@entry=RNEXT, keyname=keyname@entry=0x62d0000f0d30 "PRIMARY", key_expr=key_expr@entry=0x0, ha_rkey_mode=ha_rkey_mode@entry=HA_READ_KEY_EXACT, cond=<optimized out>, select_limit_cnt=<optimized out>, offset_limit_cnt=<optimized out>) at /data/bld/12.2-asan-ubsan/sql/sql_handler.cc:903
      #15 0x000055d56225dfdf in mysql_execute_command (thd=thd@entry=0x62c0000c0218, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:5500
      #16 0x000055d5622684e8 in mysql_parse (thd=thd@entry=0x62c0000c0218, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f2a24a54a10) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:7932
      #17 0x000055d5622715fe in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62c0000c0218, packet=packet@entry=0x6290002a3219 "", packet_length=packet_length@entry=29, blocking=blocking@entry=true) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:1896
      #18 0x000055d56227e5b2 in do_command (thd=thd@entry=0x62c0000c0218, blocking=blocking@entry=true) at /data/bld/12.2-asan-ubsan/sql/sql_parse.cc:1432
      #19 0x000055d562ad4f50 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x6080000082b8, put_in_cache=put_in_cache@entry=true) at /data/bld/12.2-asan-ubsan/sql/sql_connect.cc:1503
      #20 0x000055d562ad60b9 in handle_one_connection (arg=0x6080000082b8) at /data/bld/12.2-asan-ubsan/sql/sql_connect.cc:1415
      #21 0x000055d5647111a7 in pfs_spawn_thread (arg=0x617000005f18) at /data/bld/12.2-asan-ubsan/storage/perfschema/pfs.cc:2198
      #22 0x00007f2a30aa81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #23 0x00007f2a30b2885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

       

      Attachments

        1. r10.test
          12 kB
          Elena Stepanova

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.