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

Wrong result or Assertion `!is_v' failure upon query using rowid filter

    XMLWordPrintable

    Details

      Description

      While separately each part of the test case is fairly normal, together they make such a weird mix of optimizer features, InnoDB, locking, temporary tables, and virtual columns that it can't all be relevant. However, I couldn't get rid of any remaining component.

      --source include/have_innodb.inc
       
      CREATE TEMPORARY TABLE t1 (a INT, b INT AS (a*2), c CHAR(3), KEY(b), KEY(c)) ENGINE=InnoDB;
      INSERT INTO t1 (a,c) VALUES 
        (9,'SRB'),(3,'PRT'),(2,'KAZ'),(6,'QAT'),(9,'FRA'),(1,'VAT'),(8,'SVN'),
        (6,'PRT'),(7,'OMN'),(9,'QAT'),(9,'TUR'),(5,'CUB'),(9,'VEN'),(4,'USA'),
        (5,'YEM'),(2,'VNM'),(2,'YEM'),(1,'MEX'),(2,'NLD'),(1,'NOR'),(4,'ARG'),
        (8,'FRA'),(6,'NOR');
       
      CREATE TABLE t2 (x INT);
      LOCK TABLE t2 READ;
       
      SELECT * FROM t1 WHERE b > 17 AND c IN ('QAT', 'PRT', 'FIN');
       
      # Cleanup
      UNLOCK TABLES;
      DROP TABLE t2;
      

      The expected result is one row (9, 18, 'QAT').
      The actual result on a non-debug build is an empty set.
      A debug build produces an assertion failure:

      10.4 b55b808b

      mysqld: /data/src/10.4/storage/innobase/handler/ha_innodb.cc:7782: void ha_innobase::build_template(bool): Assertion `!is_v' failed.
      220214 21:39:55 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fc815622662 in __GI___assert_fail (assertion=0x55eb6e5f063f "!is_v", file=0x55eb6e5ec218 "/data/src/10.4/storage/innobase/handler/ha_innodb.cc", line=7782, function=0x55eb6e5f0618 "void ha_innobase::build_template(bool)") at assert.c:101
      #8  0x000055eb6ddb1db1 in ha_innobase::build_template (this=0x7fc7c01a6038, whole_row=true) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:7782
      #9  0x000055eb6ddb6918 in ha_innobase::change_active_index (this=0x7fc7c01a6038, keynr=0) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:9632
      #10 0x000055eb6ddb588a in ha_innobase::index_init (this=0x7fc7c01a6038, keynr=0) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:9186
      #11 0x000055eb6d5ee030 in handler::ha_index_init (this=0x7fc7c01a6038, idx=0, sorted=true) at /data/src/10.4/sql/handler.h:3253
      #12 0x000055eb6db72513 in QUICK_RANGE_SELECT::reset (this=0x7fc7c01aacf0) at /data/src/10.4/sql/opt_range.cc:12262
      #13 0x000055eb6d72339a in join_init_read_record (tab=0x7fc7c0018b40) at /data/src/10.4/sql/sql_select.cc:21559
      #14 0x000055eb6d721002 in sub_select (join=0x7fc7c0016820, join_tab=0x7fc7c0018b40, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:20625
      #15 0x000055eb6d7204d4 in do_select (join=0x7fc7c0016820, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:20164
      #16 0x000055eb6d6f4ec0 in JOIN::exec_inner (this=0x7fc7c0016820) at /data/src/10.4/sql/sql_select.cc:4542
      #17 0x000055eb6d6f3fd0 in JOIN::exec (this=0x7fc7c0016820) at /data/src/10.4/sql/sql_select.cc:4324
      #18 0x000055eb6d6f574a in mysql_select (thd=0x7fc7c0000d90, tables=0x7fc7c0014e50, wild_num=1, fields=..., conds=0x7fc7c0015e08, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2149845760, result=0x7fc7c00167f8, unit=0x7fc7c0004cc0, select_lex=0x7fc7c0014870) at /data/src/10.4/sql/sql_select.cc:4763
      #19 0x000055eb6d6e5026 in handle_select (thd=0x7fc7c0000d90, lex=0x7fc7c0004c00, result=0x7fc7c00167f8, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:436
      #20 0x000055eb6d6aa88a in execute_sqlcom_select (thd=0x7fc7c0000d90, all_tables=0x7fc7c0014e50) at /data/src/10.4/sql/sql_parse.cc:6449
      #21 0x000055eb6d6a1092 in mysql_execute_command (thd=0x7fc7c0000d90) at /data/src/10.4/sql/sql_parse.cc:3963
      #22 0x000055eb6d6ae81e in mysql_parse (thd=0x7fc7c0000d90, rawbuf=0x7fc7c0014798 "SELECT * FROM t1 WHERE b > 17 AND c IN ('QAT', 'PRT', 'FIN')", length=60, parser_state=0x7fc80a7ca550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
      #23 0x000055eb6d69ac97 in dispatch_command (command=COM_QUERY, thd=0x7fc7c0000d90, packet=0x7fc7c000abf1 "", packet_length=60, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
      #24 0x000055eb6d699524 in do_command (thd=0x7fc7c0000d90) at /data/src/10.4/sql/sql_parse.cc:1373
      #25 0x000055eb6d82798b in do_handle_one_connection (connect=0x55eb70a9dd00) at /data/src/10.4/sql/sql_connect.cc:1420
      #26 0x000055eb6d827633 in handle_one_connection (arg=0x55eb70a9dd00) at /data/src/10.4/sql/sql_connect.cc:1316
      #27 0x000055eb6dd42dfd in pfs_spawn_thread (arg=0x55eb70a7e270) at /data/src/10.4/storage/perfschema/pfs.cc:1869
      #28 0x00007fc815aeeea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #29 0x00007fc8156ebdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Plan:

        "query_block": {
          "select_id": 1,
          "table": {
            "table_name": "t1",
            "access_type": "range",
            "possible_keys": ["b", "c"],
            "key": "b",
            "key_length": "5",
            "used_key_parts": ["b"],
            "rowid_filter": {
              "range": {
                "key": "c",
                "used_key_parts": ["c"]
              },
              "rows": 5,
              "selectivity_pct": 21.739
            },
            "rows": 5,
            "filtered": 21.739,
            "attached_condition": "t1.c in ('QAT','PRT','FIN') and t1.b > 17"
          }
        }
      

        Attachments

          Activity

            People

            Assignee:
            psergei Sergei Petrunia
            Reporter:
            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.