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

Assertion `cond_selectivity <= 1.000000001' failed

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      CREATE TABLE t1 (a INT, b INT, KEY(a));
      INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100;
      SET optimizer_join_limit_pref_ratio=1;
      SELECT * FROM seq_1_to_200, t1 WHERE a > 0 ORDER BY a LIMIT 1;
      

      Leads to:

      CS 13.2.0 c894d97781b54fbf074677c9d67f81cd60a162ac (Debug, Clang 22.1.8-20260621) Build 26/10/2026

      mariadbd: /test/13.1_dbg/sql/sql_select.cc:34148: bool get_range_limit_read_cost(const POSITION *, const TABLE *, uint, ha_rows, ha_rows, double *, double *): Assertion `cond_selectivity <= 1.000000001' failed.
      

      CS 13.2.0 c894d97781b54fbf074677c9d67f81cd60a162ac (Debug, Clang 22.1.8-20260621) Build 26/10/2026

      Core was generated by `/test/MD261026-mariadb-13.2.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --loo'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 1888401)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
      #3  0x0000704f8d24527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x0000704f8d2288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x0000704f8d22881b in __assert_fail_base (fmt=0x704f8d3d1208 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x58fd17bfb37c "cond_selectivity <= 1.000000001", file=file@entry=0x58fd17bf4b53 "/test/13.1_dbg/sql/sql_select.cc", line=line@entry=34148, function=function@entry=0x58fd17bfb39c "bool get_range_limit_read_cost(const POSITION *, const TABLE *, uint, ha_rows, ha_rows, double *, double *)")at ./assert/assert.c:96
      #6  0x0000704f8d23b517 in __assert_fail (assertion=0x58fd17bfb37c "cond_selectivity <= 1.000000001", file=0x58fd17bf4b53 "/test/13.1_dbg/sql/sql_select.cc", line=34148, function=0x58fd17bfb39c "bool get_range_limit_read_cost(const POSITION *, const TABLE *, uint, ha_rows, ha_rows, double *, double *)")at ./assert/assert.c:105
      #7  0x000058fd16c904e2 in get_range_limit_read_cost (pos=0x684e74020470, table=0x684e7402c0e0, keynr=0, rows_limit_arg=1, rows_to_scan=0, read_cost=0x704f64b0ace8, read_rows=0x704f64b0ace0)at /test/13.1_dbg/sql/sql_select.cc:34148
      #8  0x000058fd16c64350 in test_if_cheaper_ordering (in_join_optimizer=true, tab=0x684e7401f0e8, order=0x684e7401c960, table=0x684e7402c0e0, usable_keys={static BITS_PER_ELEMENT = 64, static ARRAY_ELEMENTS = 1, static ALL_BITS_SET = 18446744073709551615, buffer = {1}}, ref_key=64, select_limit_arg=1, new_key=0x704f64b0aef0, new_key_direction=0x704f64b0aee4, new_select_limit=0x704f64b0aed0, new_read_time=0x704f64b0aec8, new_used_key_parts=0x704f64b0aeec, saved_best_key_parts=0x704f64b0aee8)at /test/13.1_dbg/sql/sql_select.cc:34530
      #9  0x000058fd16c62ffe in test_if_skip_sort_order_early (join=0x684e7401de50, access_method_changed=0x704f64b0afc2, new_access_cost=0x704f64b0afb8)at /test/13.1_dbg/sql/sql_select.cc:12087
      #10 0x000058fd16c62139 in join_limit_shortcut_finalize_plan (join=0x684e7401de50, cost=0x704f64b0b0c0)at /test/13.1_dbg/sql/sql_select.cc:12217
      #11 0x000058fd16c605dd in choose_plan (join=0x684e7401de50, join_tables=3, emb_sjm_nest=0x0) at /test/13.1_dbg/sql/sql_select.cc:10627
      #12 0x000058fd16c42d1f in make_join_statistics (join=0x684e7401de50, tables_list=@0x684e7401a758: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x684e7401e620, last = 0x684e7401e630, elements = 2}, <No data fields>}, keyuse_array=0x684e7401e1b0) at /test/13.1_dbg/sql/sql_select.cc:6403
      #13 0x000058fd16c3adf9 in JOIN::optimize_inner (this=0x684e7401de50)at /test/13.1_dbg/sql/sql_select.cc:2779
      #14 0x000058fd16c38ac6 in JOIN::optimize (this=0x684e7401de50)at /test/13.1_dbg/sql/sql_select.cc:2032
      #15 0x000058fd16c3128d in mysql_select (thd=0x684e74000d60, tables=0x684e7401ac00, fields=@0x684e7401a7f8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x684e7401ab70, last = 0x684e7401ea70, elements = 3}, <No data fields>}, conds=0x684e7401bd20, og_num=1, order=0x684e7401c960, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x684e7401de20, unit=0x684e740052f8, select_lex=0x684e7401a540)at /test/13.1_dbg/sql/sql_select.cc:5447
      #16 0x000058fd16c30e8d in handle_select (thd=0x684e74000d60, lex=0x684e74005218, result=0x684e7401de20, setup_tables_done_option=0)at /test/13.1_dbg/sql/sql_select.cc:652
      #17 0x000058fd16bd57b6 in execute_sqlcom_select (thd=0x684e74000d60, all_tables=0x684e7401ac00) at /test/13.1_dbg/sql/sql_parse.cc:6266
      #18 0x000058fd16bcba4b in mysql_execute_command (thd=0x684e74000d60, is_called_from_prepared_stmt=false) at /test/13.1_dbg/sql/sql_parse.cc:4038
      #19 0x000058fd16bc4718 in mysql_parse (thd=0x684e74000d60, rawbuf=0x684e7401a460 "SELECT * FROM seq_1_to_200, t1 WHERE a > 0 ORDER BY a LIMIT 1", length=61, parser_state=0x704f64b0d9c0)at /test/13.1_dbg/sql/sql_parse.cc:8005
      #20 0x000058fd16bc1ece in dispatch_command (command=COM_QUERY, thd=0x684e74000d60, packet=0x684e7400b691 "SELECT * FROM seq_1_to_200, t1 WHERE a > 0 ORDER BY a LIMIT 1", packet_length=61, blocking=true)at /test/13.1_dbg/sql/sql_parse.cc:1903
      #21 0x000058fd16bc519a in do_command (thd=0x684e74000d60, blocking=true)at /test/13.1_dbg/sql/sql_parse.cc:1437
      #22 0x000058fd16da00ce in do_handle_one_connection (connect=0x58fd30e4ef20, put_in_cache=true) at /test/13.1_dbg/sql/sql_connect.cc:1514
      #23 0x000058fd16d9feb1 in handle_one_connection (arg=0x58fd30de78d0)at /test/13.1_dbg/sql/sql_connect.cc:1426
      #24 0x0000704f8d29cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #25 0x0000704f8d329ecc in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.11  dbg  261026  6a063120d4d3d451bff3ea84b3ffbee288b33be8  No bug found                  
      CS  10.11  opt  261026  6a063120d4d3d451bff3ea84b3ffbee288b33be8  No bug found                  
      CS  11.4   dbg  261026  b6406d42c8e26be3d86a4a743180f6b415a4559b  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      CS  11.4   opt  261026  b6406d42c8e26be3d86a4a743180f6b415a4559b  No bug found                  
      CS  11.8   dbg  261026  274dd0d8d90bc773090d13303b8d5e36d2390241  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      CS  11.8   opt  261026  274dd0d8d90bc773090d13303b8d5e36d2390241  No bug found                  
      CS  12.3   dbg  261026  788a07c52132d9f42b6991e599510c62d1625c0f  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      CS  12.3   opt  261026  788a07c52132d9f42b6991e599510c62d1625c0f  No bug found                  
      CS  13.0   dbg  261026  620a4b5624222048fece7fe1789978ae0675cae2  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      CS  13.0   opt  261026  620a4b5624222048fece7fe1789978ae0675cae2  No bug found                  
      CS  13.2   dbg  261026  c894d97781b54fbf074677c9d67f81cd60a162ac  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      CS  13.2   opt  261026  c894d97781b54fbf074677c9d67f81cd60a162ac  No bug found                  
      ES  10.6   dbg  261026  45fbb1583d8cdcc7da5a123a844b3bf512f31c9d  No bug found                  
      ES  10.6   opt  261026  45fbb1583d8cdcc7da5a123a844b3bf512f31c9d  No bug found                  
      ES  11.4   dbg  261026  6b2ae48e6e2488060adfdd02a7114bb60d4d150c  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      ES  11.4   opt  261026  6b2ae48e6e2488060adfdd02a7114bb60d4d150c  No bug found                  
      ES  11.8   dbg  261026  6e6ba60bdc2b3f478513c5afa3faa062d8e73736  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      ES  11.8   opt  261026  6e6ba60bdc2b3f478513c5afa3faa062d8e73736  No bug found                  
      ES  12.3   dbg  261026  781803ca9943d806ecb4b3b3fb39264dfafe1cf0  cond_selectivity <= 1.000000001|SIGABRT|get_range_limit_read_cost|test_if_cheaper_ordering|test_if_skip_sort_order_early|join_limit_shortcut_finalize_plan
      ES  12.3   opt  261026  781803ca9943d806ecb4b3b3fb39264dfafe1cf0  No bug found                  
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            saahil Saahil Alam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 1h
                1h

                Git Integration

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