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

Assertion `table_records == 0 || sel <= s->table->opt_range_condition_rows / table_records'

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 11.0, 11.1, 11.2
    • 11.1
    • Optimizer

    Description

      # MTR runs with perfschema ON, we need it OFF
      --let $restart_parameters= --performance-schema=off
      --source include/restart_mysqld.inc
       
      CREATE TABLE t1 (a VARCHAR(1000), KEY(a(100))) CHARACTER SET utf8;
      INSERT INTO t1 (a) VALUES (''),(''),('');
      ANALYZE TABLE t1 PERSISTENT FOR ALL;
      CREATE TABLE t2 (b VARCHAR(8));
      INSERT INTO t2 VALUES ('foo'),('bar');
       
      CREATE VIEW v3 AS SELECT OBJECT_TYPE FROM performance_schema.metadata_locks;
       
      SELECT v3.* FROM v3 LEFT JOIN (SELECT t1sq.a FROM (SELECT * FROM t1) t1sq LEFT JOIN t2 ON t2.b = t1sq.a WHERE t1sq.a = 'x' GROUP BY a) sq ON sq.a = v3.OBJECT_TYPE;
       
      # Cleanup
      DROP VIEW v3;
      DROP TABLE t1, t2;
      

      11.0 9ad7c899

      mariadbd: /data/src/11.2/sql/sql_select.cc:7923: double apply_selectivity_for_table(JOIN_TAB*, uint): Assertion `table_records == 0 || sel <= s->table->opt_range_condition_rows / table_records' failed.
      230909 20:02:36 [ERROR] mysqld got signal 6 ;
       
      #9  0x00007fd2a4a53df2 in __GI___assert_fail (assertion=0x557947b67840 "table_records == 0 || sel <= s->table->opt_range_condition_rows / table_records", file=0x557947b62640 "/data/src/11.2/sql/sql_select.cc", line=7923, function=0x557947b677e0 "double apply_selectivity_for_table(JOIN_TAB*, uint)") at ./assert/assert.c:101
      #10 0x0000557945b9f449 in apply_selectivity_for_table (s=0x62900010b1a8, use_cond_selectivity=4) at /data/src/11.2/sql/sql_select.cc:7923
      #11 0x0000557945ba8298 in best_access_path (join=0x6290001025d0, s=0x62900010b1a8, remaining_tables=2, join_positions=0x62900010b858, idx=1, disable_jbuf=false, record_count=1, pos=0x62900010bef0, loose_scan_pos=0x62900010c040) at /data/src/11.2/sql/sql_select.cc:9449
      #12 0x0000557945bb2212 in get_costs_for_tables (join=0x6290001025d0, remaining_tables=2, idx=1, record_count=0, trace_one_table=0x7fd2a16e62f0, pos=0x62900010b818, store_position=0x7fd2a16e6210, allowed_tables=0x7fd2a16e6250, stop_on_eq_ref=false) at /data/src/11.2/sql/sql_select.cc:11177
      #13 0x0000557945bb34d1 in best_extension_by_limited_search (join=0x6290001025d0, remaining_tables=2, idx=1, record_count=0, read_time=1.01, search_depth=61, use_cond_selectivity=4, processed_eq_ref_tables=0x7fd2a16e6610) at /data/src/11.2/sql/sql_select.cc:11434
      #14 0x0000557945bb4f62 in best_extension_by_limited_search (join=0x6290001025d0, remaining_tables=3, idx=0, record_count=1, read_time=0, search_depth=62, use_cond_selectivity=4, processed_eq_ref_tables=0x7fd2a16e68f0) at /data/src/11.2/sql/sql_select.cc:11660
      #15 0x0000557945badf27 in greedy_search (join=0x6290001025d0, remaining_tables=3, search_depth=62, use_cond_selectivity=4) at /data/src/11.2/sql/sql_select.cc:10405
      #16 0x0000557945bab985 in choose_plan (join=0x6290001025d0, join_tables=3, emb_sjm_nest=0x0) at /data/src/11.2/sql/sql_select.cc:9924
      #17 0x0000557945b915c6 in make_join_statistics (join=0x6290001025d0, tables_list=..., keyuse_array=0x629000102938) at /data/src/11.2/sql/sql_select.cc:6179
      #18 0x0000557945b6d096 in JOIN::optimize_inner (this=0x6290001025d0) at /data/src/11.2/sql/sql_select.cc:2618
      #19 0x0000557945b6602f in JOIN::optimize (this=0x6290001025d0) at /data/src/11.2/sql/sql_select.cc:1944
      #20 0x0000557945b87c08 in mysql_select (thd=0x62c000080218, tables=0x6290000d7a58, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x6290001025a0, unit=0x62c000084730, select_lex=0x6290000d73f0) at /data/src/11.2/sql/sql_select.cc:5229
      #21 0x0000557945b57567 in handle_select (thd=0x62c000080218, lex=0x62c000084650, result=0x6290001025a0, setup_tables_done_option=0) at /data/src/11.2/sql/sql_select.cc:628
      #22 0x0000557945a7e5fd in execute_sqlcom_select (thd=0x62c000080218, all_tables=0x6290000d7a58) at /data/src/11.2/sql/sql_parse.cc:6065
      #23 0x0000557945a6f03c in mysql_execute_command (thd=0x62c000080218, is_called_from_prepared_stmt=false) at /data/src/11.2/sql/sql_parse.cc:3955
      #24 0x0000557945a890d7 in mysql_parse (thd=0x62c000080218, rawbuf=0x6290000d7238 "SELECT v3.* FROM v3 LEFT JOIN (SELECT t1sq.a FROM (SELECT * FROM t1) t1sq LEFT JOIN t2 ON t2.b = t1sq.a WHERE t1sq.a = 'x' GROUP BY a) sq ON sq.a = v3.OBJECT_TYPE", length=162, parser_state=0x7fd2a16e89f0) at /data/src/11.2/sql/sql_parse.cc:7811
      #25 0x0000557945a61491 in dispatch_command (command=COM_QUERY, thd=0x62c000080218, packet=0x6290000cd219 "SELECT v3.* FROM v3 LEFT JOIN (SELECT t1sq.a FROM (SELECT * FROM t1) t1sq LEFT JOIN t2 ON t2.b = t1sq.a WHERE t1sq.a = 'x' GROUP BY a) sq ON sq.a = v3.OBJECT_TYPE", packet_length=162, blocking=true) at /data/src/11.2/sql/sql_parse.cc:1893
      #26 0x0000557945a5e1ce in do_command (thd=0x62c000080218, blocking=true) at /data/src/11.2/sql/sql_parse.cc:1406
      #27 0x0000557945f29fac in do_handle_one_connection (connect=0x608000002938, put_in_cache=true) at /data/src/11.2/sql/sql_connect.cc:1445
      #28 0x0000557945f2996d in handle_one_connection (arg=0x608000002938) at /data/src/11.2/sql/sql_connect.cc:1347
      #29 0x0000557946b52652 in pfs_spawn_thread (arg=0x617000005498) at /data/src/11.2/storage/perfschema/pfs.cc:2201
      #30 0x00007fd2a4aa7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #31 0x00007fd2a4b285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      EXPLAIN on a debug build also fails. Explain on a non-debug build, assuming they're the same:

      11.0 5f6e9874

      EXPLAIN EXTENDED SELECT v3.* FROM v3 LEFT JOIN (SELECT t1sq.a FROM (SELECT * FROM t1) t1sq LEFT JOIN t2 ON t2.b = t1sq.a WHERE t1sq.a = 'x' GROUP BY a) sq ON sq.a = v3.OBJECT_TYPE;
      id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
      1	PRIMARY	metadata_locks	ALL	NULL	NULL	NULL	NULL	0	0.00	
      1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where; Using join buffer (flat, BNL join)
      2	DERIVED	t1	ref	a	a	303	const	1	100.00	Using where
      2	DERIVED	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where; Using join buffer (flat, BNL join)
      

      The failure started happening on 11.0 after this merge in 11.0.2. It's a fairly big merge, I cannot determine which commit from it is guilty.

      commit 0005f2f06c8e1aea4915887decad67885108a929
      Merge: 5ba3bafb834 4e2b93dffef
      Author: Sergei Golubchik
      Date:   Mon Jun 5 19:27:00 2023 +0200
       
          Merge branch 'bb-10.11-release' into bb-11.0-release
      

      Attachments

        Activity

          People

            monty Michael Widenius
            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.