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

Failing assertion: block->magic_n == MEM_BLOCK_MAGIC_N

Details

    Description

      --source include/have_innodb.inc
      CREATE TABLE t1 (
          pk INTEGER AUTO_INCREMENT,
          i INT,
          vi INT AS (i*2) VIRTUAL,
          d DATE,
          vd DATE AS (DATE_SUB(d, INTERVAL 1 DAY)) VIRTUAL,
          t TIME,
          vt TIME AS (TIME(t)) VIRTUAL,
          dt DATETIME,
          vdt DATETIME AS (DATE_ADD(dt, INTERVAL 1 HOUR)) VIRTUAL,
          c VARCHAR(8),
          varchar_column VARCHAR(8) AS (CONCAT('vrt-',c)) VIRTUAL,
       
          PRIMARY KEY (pk),
          KEY (vi),
          KEY (vd),
          KEY (t),
          KEY (vdt),
          KEY (varchar_column)
      ) ENGINE=InnoDB;
      CREATE TABLE t2 (i INT) ENGINE=InnoDB;
      ALTER TABLE t1 ADD COLUMN col INT;
      SELECT * FROM t1 WHERE vi < 2;
      DROP TABLE t1, t2;
      

      10.2 348ccb6f038

      2017-01-07 02:03:19 0x7fec30d6e300  InnoDB: Assertion failure in file /data/src/10.2/storage/innobase/include/mem0mem.ic line 155
      InnoDB: Failing assertion: block->magic_n == MEM_BLOCK_MAGIC_N
       
      #5  0x00007fec2d17d448 in __GI_abort () at abort.c:89
      #6  0x00007fec3032cf20 in ut_dbg_assertion_failed (expr=0x7fec30822fa0 "block->magic_n == MEM_BLOCK_MAGIC_N", file=0x7fec30822ef8 "/data/src/10.2/storage/innobase/include/mem0mem.ic", line=155) at /data/src/10.2/storage/innobase/ut/ut0dbg.cc:59
      #7  0x00007fec301b4a6b in mem_block_validate (block=0x7fec070f1b00) at /data/src/10.2/storage/innobase/include/mem0mem.ic:155
      #8  0x00007fec301b5945 in mem_heap_block_free (heap=0x7fec07052b00, block=0x7fec070f1b00) at /data/src/10.2/storage/innobase/mem/mem0mem.cc:427
      #9  0x00007fec30406596 in mem_heap_free (heap=0x7fec07052b00) at /data/src/10.2/storage/innobase/include/mem0mem.ic:534
      #10 0x00007fec304095f1 in dict_mem_index_free (index=0x7fec07167608) at /data/src/10.2/storage/innobase/dict/dict0mem.cc:995
      #11 0x00007fec303e8163 in dict_index_remove_from_cache_low (table=0x7fec07165a08, index=0x7fec07167608, lru_evict=0) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:2755
      #12 0x00007fec303e661c in dict_table_remove_from_cache_low (table=0x7fec07165a08, lru_evict=0) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:2100
      #13 0x00007fec303e6bfc in dict_table_remove_from_cache (table=0x7fec07165a08) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:2167
      #14 0x00007fec30256541 in row_drop_table_from_cache (tablename=0x7fec071f1a08 "test/t2", table=0x7fec07165a08, trx=0x7fec23c00d58) at /data/src/10.2/storage/innobase/row/row0mysql.cc:3597
      #15 0x00007fec30257a2d in row_drop_table_for_mysql (name=0x7fec30d6a3c0 "test/t2", trx=0x7fec23c00d58, drop_db=false, create_failed=0, nonatomic=true) at /data/src/10.2/storage/innobase/row/row0mysql.cc:4166
      er/ha_innodb.cc:14704
      #17 0x00007fec2fec6294 in handler::ha_delete_table (this=0x7fec07065950, name=0x7fec30d6bef0 "./test/t2") at /data/src/10.2/sql/handler.cc:4328
      #18 0x00007fec2fec0d41 in ha_delete_table (thd=0x7fec07016070, table_type=0x7fec2c813af0, path=0x7fec30d6bef0 "./test/t2", db=0x7fec07064da8 "test", alias=0x7fec07064768 "t2", generate_warning=true) at /data/src/10.2/sql/handler.cc:2351
      #19 0x00007fec2fd1340b in mysql_rm_table_no_locks (thd=0x7fec07016070, tables=0x7fec07064158, if_exists=false, drop_temporary=false, drop_view=false, dont_log_query=false, dont_free_locks=false) at /data/src/10.2/sql/sql_table.cc:2470
      #20 0x00007fec2fd1262e in mysql_rm_table (thd=0x7fec07016070, tables=0x7fec07064158, if_exists=0 '\000', drop_temporary=0 '\000') at /data/src/10.2/sql/sql_table.cc:2090
      #21 0x00007fec2fc581ed in mysql_execute_command (thd=0x7fec07016070) at /data/src/10.2/sql/sql_parse.cc:4690
      #22 0x00007fec2fc62328 in mysql_parse (thd=0x7fec07016070, rawbuf=0x7fec07064088 "DROP TABLE t1, t2", length=17, parser_state=0x7fec30d6cdd0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7839
      #23 0x00007fec2fc4feee in dispatch_command (command=COM_QUERY, thd=0x7fec07016070, packet=0x7fec07058071 "DROP TABLE t1, t2", packet_length=17, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1799
      #24 0x00007fec2fc4e8c8 in do_command (thd=0x7fec07016070) at /data/src/10.2/sql/sql_parse.cc:1359
      #25 0x00007fec2fd9673e in do_handle_one_connection (connect=0x7fec2c871f70) at /data/src/10.2/sql/sql_connect.cc:1354
      #26 0x00007fec2fd964cb in handle_one_connection (arg=0x7fec2c871f70) at /data/src/10.2/sql/sql_connect.cc:1260
      #27 0x00007fec300d532c in pfs_spawn_thread (arg=0x7fec19fed770) at /data/src/10.2/storage/perfschema/pfs.cc:1862
      #28 0x00007fec2f2820a4 in start_thread (arg=0x7fec30d6e300) at pthread_create.c:309
      #29 0x00007fec2d22f87d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
      

      Attachments

        Issue Links

          Activity

            Also reproducible on bb-10.2-monty 4ec3e60ae3.

            elenst Elena Stepanova added a comment - Also reproducible on bb-10.2-monty 4ec3e60ae3.
            marko Marko Mäkelä added a comment - - edited

            Here is a little shorter version of the test:

            --source include/have_innodb.inc
            CREATE TABLE t1 (
                i INT PRIMARY KEY, vi INT AS (i*2) VIRTUAL UNIQUE
            ) ENGINE=InnoDB;
            CREATE TABLE t2 (i INT) ENGINE=InnoDB;
            ALTER TABLE t1 ADD COLUMN col INT;
            SELECT * FROM t1 WHERE vi < 2;
            DROP TABLE t1, t2;
            

            Curiously, both PRIMARY KEY and t2 are needed.

            marko Marko Mäkelä added a comment - - edited Here is a little shorter version of the test: --source include/have_innodb.inc CREATE TABLE t1 ( i INT PRIMARY KEY, vi INT AS (i*2) VIRTUAL UNIQUE ) ENGINE=InnoDB; CREATE TABLE t2 (i INT) ENGINE=InnoDB; ALTER TABLE t1 ADD COLUMN col INT; SELECT * FROM t1 WHERE vi < 2; DROP TABLE t1, t2; Curiously, both PRIMARY KEY and t2 are needed.

            Issue was that the m_prebuilt array was reused without resetting a counter, which caused a memory overrun.

            monty Michael Widenius added a comment - Issue was that the m_prebuilt array was reused without resetting a counter, which caused a memory overrun.

            For some reason, compared to MySQL 5.7, a goto had been added in the MariaDB version of the code. Why did MariaDB disable index condition pushdown (ICP) when virtual columns exist? Monty came up with this patch, which seems to fix the problem:

            diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
            index 8754a561dac..3e7574a6568 100644
            --- a/storage/innobase/handler/ha_innodb.cc
            +++ b/storage/innobase/handler/ha_innodb.cc
            @@ -8494,8 +8494,10 @@ ha_innobase::build_template(
             			if (innobase_is_v_fld(table->field[i])) {
             				index_contains = dict_index_contains_col_or_prefix(
             					index, num_v, true);
            -                                if (index_contains)
            -                                        goto no_icp;
            +				if (index_contains) {
            +					m_prebuilt->n_template = 0;
            +					goto no_icp;
            +				}
             			} else {
             				index_contains = dict_index_contains_col_or_prefix(
             					index, i - num_v, false);
            

            marko Marko Mäkelä added a comment - For some reason, compared to MySQL 5.7, a goto had been added in the MariaDB version of the code. Why did MariaDB disable index condition pushdown (ICP) when virtual columns exist? Monty came up with this patch, which seems to fix the problem: diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8754a561dac..3e7574a6568 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -8494,8 +8494,10 @@ ha_innobase::build_template( if (innobase_is_v_fld(table->field[i])) { index_contains = dict_index_contains_col_or_prefix( index, num_v, true); - if (index_contains) - goto no_icp; + if (index_contains) { + m_prebuilt->n_template = 0; + goto no_icp; + } } else { index_contains = dict_index_contains_col_or_prefix( index, i - num_v, false);

            Pushed into bb-10.2-monty for testing

            monty Michael Widenius added a comment - Pushed into bb-10.2-monty for testing

            I've disabled icp on virtual columns because it didn't work (so I believed), see commit 6eaa5fd21081 and the test case therein

            serg Sergei Golubchik added a comment - I've disabled icp on virtual columns because it didn't work (so I believed), see commit 6eaa5fd21081 and the test case therein

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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