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

Assertion with optimizer_join_limit_pref_ratio and 1-table select

    XMLWordPrintable

Details

    Description

      Server crashes when selecting more rows (with order by clause) than sql_select_limit after enabling optimizer_join_limit_pref_ratio.

      SET SESSION sql_select_limit=1;
      SET optimizer_join_limit_pref_ratio=1;
      CREATE TABLE t1 (c1 INT, INDEX(c1));
      INSERT INTO t1  VALUES (1),(2);
      SELECT * FROM t1  ORDER BY c1;
      

      Leads to

      CS 11.6.2 ba7088d462c326c9df7de97a46fe69419cd7e116 (Debug)

      mariadbd: /test/11.6_dbg/sql/optimizer_costs.h:132: double COST_ADD(double, double): Assertion `c >= 0' failed.
      

      CS 11.6.2 ba7088d462c326c9df7de97a46fe69419cd7e116 (Debug)

      Core was generated by `/test/MD031024-mariadb-11.6.2-linux-x86_64-dbg/bin/mariadbd --no-defaults --max'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      [Current thread is 1 (Thread 0x1516d00d2700 (LWP 2810560))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x00001516d3fb5859 in __GI_abort () at abort.c:79
      #2  0x00001516d3fb5729 in __assert_fail_base (fmt=0x1516d414b588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5595a384c2b2 "c >= 0", file=0x5595a384dc88 "/test/11.6_dbg/sql/optimizer_costs.h", line=132, function=<optimized out>) at assert.c:92
      #3  0x00001516d3fc6fd6 in __GI___assert_fail (assertion=assertion@entry=0x5595a384c2b2 "c >= 0", file=file@entry=0x5595a384dc88 "/test/11.6_dbg/sql/optimizer_costs.h", line=line@entry=132, function=function@entry=0x5595a384e5d0 "double COST_ADD(double, double)") at assert.c:101
      #4  0x00005595a2b2772c in COST_ADD (d=0.0017926050000000001, c=-3.1999999999999999e-05) at /test/11.6_dbg/sql/optimizer_costs.h:132
      #5  recompute_join_cost_with_limit (join=join@entry=0x15168801c328, skip_sorting=skip_sorting@entry=true, first_table_cost=<optimized out>, fraction=fraction@entry=0.5) at /test/11.6_dbg/sql/sql_select.cc:11624
      #6  0x00005595a2b27c03 in join_limit_shortcut_finalize_plan (join=join@entry=0x15168801c328, cost=cost@entry=0x1516d00d0040) at /test/11.6_dbg/sql/sql_select.cc:11695
      #7  0x00005595a2b3cb3b in choose_plan (join=join@entry=0x15168801c328, join_tables=1, emb_sjm_nest=emb_sjm_nest@entry=0x0) at /test/11.6_dbg/sql/sql_select.cc:10122
      #8  0x00005595a2b65739 in make_join_statistics (join=join@entry=0x15168801c328, tables_list=@0x15168801acf0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x15168801cae8, last = 0x15168801cae8, elements = 1}, <No data fields>}, keyuse_array=keyuse_array@entry=0x15168801c688) at /test/11.6_dbg/sql/sql_select.cc:6327
      #9  0x00005595a2b6cea7 in JOIN::optimize_inner (this=this@entry=0x15168801c328) at /test/11.6_dbg/sql/sql_select.cc:2705
      #10 0x00005595a2b6d42f in JOIN::optimize (this=this@entry=0x15168801c328) at /test/11.6_dbg/sql/sql_select.cc:2003
      #11 0x00005595a2b6d54f in mysql_select (thd=thd@entry=0x151688000d48, tables=0x15168801b110, fields=@0x15168801ad90: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x15168801b0c0, last = 0x15168801b0c0, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x15168801c1b8, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x15168801c300, unit=0x151688005248, select_lex=0x15168801aad8) at /test/11.6_dbg/sql/sql_select.cc:5345
      #12 0x00005595a2b6ddd9 in handle_select (thd=thd@entry=0x151688000d48, lex=lex@entry=0x151688005168, result=result@entry=0x15168801c300, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/11.6_dbg/sql/sql_select.cc:642
      #13 0x00005595a2ac84c0 in execute_sqlcom_select (thd=thd@entry=0x151688000d48, all_tables=0x15168801b110) at /test/11.6_dbg/sql/sql_parse.cc:6163
      #14 0x00005595a2ad0bb8 in mysql_execute_command (thd=thd@entry=0x151688000d48, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.6_dbg/sql/sql_parse.cc:3954
      #15 0x00005595a2ac166e in mysql_parse (thd=thd@entry=0x151688000d48, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1516d00d1270) at /test/11.6_dbg/sql/sql_parse.cc:7885
      #16 0x00005595a2ad8b2b in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x151688000d48, packet=packet@entry=0x15168800b249 "SELECT * FROM t1  ORDER BY c1", packet_length=packet_length@entry=29, blocking=blocking@entry=true) at /test/11.6_dbg/sql/sql_class.h:1640
      #17 0x00005595a2adb62e in do_command (thd=0x151688000d48, blocking=blocking@entry=true) at /test/11.6_dbg/sql/sql_parse.cc:1405
      #18 0x00005595a2c66309 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5595a64b0608, put_in_cache=put_in_cache@entry=true) at /test/11.6_dbg/sql/sql_connect.cc:1448
      #19 0x00005595a2c668ca in handle_one_connection (arg=arg@entry=0x5595a64b0608) at /test/11.6_dbg/sql/sql_connect.cc:1350
      #20 0x00005595a30f420a in pfs_spawn_thread (arg=0x5595a6419268) at /test/11.6_dbg/storage/perfschema/pfs.cc:2198
      #21 0x00001516d44c6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #22 0x00001516d40b2133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              ramesh Ramesh Sivaraman
              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.