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

Assertion `next_emb->nested_join->counter <= next_emb->nested_join->n_tables' failed

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • None
    • N/A
    • Optimizer
    • None
    • Can result in hang or crash
    • Q2/2026 Server Development

    Description

      Server Crash seen while testing MDEV-39014

      Issue:

      ---------
      mariadbd: /home/ppandith/wl-39014/sql/sql_select.cc:21150: bool check_interleaving_with_nj(JOIN_TAB*): Assertion `next_emb->nested_join->counter <= next_emb->nested_join->n_tables' failed.

      Version:

      ----------------
      Branch : 13.2-mdev-39014-full-join-p2
      commit : 8c390c9c720faa7a2974df555faa531d6096c246
      Version : 13.0.1

      How to Repro:

      ---------------

      create table t1(pk int);
      create table t2(pk int);
       
      SELECT table1.`pk` FROM  t1 AS table1 straight_join ( SELECT alias1.* FROM t2 AS alias1 FULL JOIN t1 as alias2 ON (1 ) ) AS table2   ON ( table1.pk IN ( SELECT t2.pk  FROM t1  LEFT JOIN t2 ON (1 ) ) ) ;
      

      Stack trace:

      #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=6) at ./nptl/pthread_kill.c:89
      #3  my_write_core (sig=6) at /home/ppandith/wl-39014/mysys/stacktrace.c:424
      #4  handle_fatal_signal (sig=6) at /home/ppandith/wl-39014/sql/signal_handler.cc:298
      #5  <signal handler called>
      #6  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
      #7  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
      #8  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
      #9  __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
      #10 __GI_abort () at ./stdlib/abort.c:79
      #11 __assert_fail_base (fmt="%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
          assertion=assertion@entry="next_emb->nested_join->counter <= next_emb->nested_join->n_tables", 
          file=file@entry="/home/ppandith/wl-39014/sql/sql_select.cc", line=line@entry=21150, 
          function=function@entry="bool check_interleaving_with_nj(JOIN_TAB*)") at ./assert/assert.c:96
      #12 __assert_fail (assertion="next_emb->nested_join->counter <= next_emb->nested_join->n_tables", 
          file="/home/ppandith/wl-39014/sql/sql_select.cc", line=21150, function="bool check_interleaving_with_nj(JOIN_TAB*)")
          at ./assert/assert.c:105
      #13 check_interleaving_with_nj (next_tab=) at /home/ppandith/wl-39014/sql/sql_select.cc:21150
      #14 get_costs_for_tables (join=, remaining_tables=16, idx=4, record_count=1, trace_one_table=, pos=, store_position=, allowed_tables=, 
          stop_on_eq_ref=false) at /home/ppandith/wl-39014/sql/sql_select.cc:11803
      #15 best_extension_by_limited_search (join=, remaining_tables=16, idx=4, record_count=1, read_time=0.044071200000000005, 
          search_depth=58, use_cond_selectivity=4, processed_eq_ref_tables=) at /home/ppandith/wl-39014/sql/sql_select.cc:12387
      #16 best_extension_by_limited_search (join=, remaining_tables=24, idx=3, record_count=1, read_time=0.033053400000000004, 
          search_depth=59, use_cond_selectivity=4, processed_eq_ref_tables=) at /home/ppandith/wl-39014/sql/sql_select.cc:12612
      #17 best_extension_by_limited_search (join=, remaining_tables=28, idx=2, record_count=1, read_time=0.022035600000000002, 
          search_depth=60, use_cond_selectivity=4, processed_eq_ref_tables=) at /home/ppandith/wl-39014/sql/sql_select.cc:12612
      #18 best_extension_by_limited_search (join=, remaining_tables=30, idx=1, record_count=1, read_time=0.011017800000000001, 
          search_depth=61, use_cond_selectivity=4, processed_eq_ref_tables=) at /home/ppandith/wl-39014/sql/sql_select.cc:12612
      #19 best_extension_by_limited_search (join=, remaining_tables=31, idx=0, record_count=1, read_time=0, search_depth=62, 
          use_cond_selectivity=4, processed_eq_ref_tables=) at /home/ppandith/wl-39014/sql/sql_select.cc:12612
      #20 greedy_search (join=, remaining_tables=31, search_depth=62, use_cond_selectivity=4)
          at /home/ppandith/wl-39014/sql/sql_select.cc:11034
      #21 choose_plan (join=, join_tables=31, emb_sjm_nest=) at /home/ppandith/wl-39014/sql/sql_select.cc:10539
      #22 make_join_statistics (join=, tables_list=..., keyuse_array=) at /home/ppandith/wl-39014/sql/sql_select.cc:6555
      #23 JOIN::optimize_inner (this=) at /home/ppandith/wl-39014/sql/sql_select.cc:2895
      #24 JOIN::optimize (this=) at /home/ppandith/wl-39014/sql/sql_select.cc:2145
      #25 mysql_select (thd=, tables=, fields=..., conds=, og_num=0, order=, group=, having=, proc_param=, select_options=2164525824, 
          result=, unit=, select_lex=) at /home/ppandith/wl-39014/sql/sql_select.cc:5557
      #26 handle_select (thd=, lex=, result=, setup_tables_done_option=0) at /home/ppandith/wl-39014/sql/sql_select.cc:765
      #27 execute_sqlcom_select (thd=, all_tables=) at /home/ppandith/wl-39014/sql/sql_parse.cc:6213
      #28 mysql_execute_command (thd=, is_called_from_prepared_stmt=false) at /home/ppandith/wl-39014/sql/sql_parse.cc:3989
      #29 mysql_parse (thd=, 
          rawbuf="SELECT table1.`pk` FROM  t1 AS table1 straight_join ( SELECT alias1.* FROM t2 AS alias1 FULL JOIN t1 as alias2 ON (1 ) ) AS table2   ON ( table1.pk IN ( SELECT t2.pk  FROM t1  LEFT JOIN t2 ON (1 ) ) )", length=200, parser_state=)
          at /home/ppandith/wl-39014/sql/sql_parse.cc:7941
      #30 dispatch_command (command=COM_QUERY, thd=, 
          packet="SELECT table1.`pk` FROM  t1 AS table1 straight_join ( SELECT alias1.* FROM t2 AS alias1 FULL JOIN t1 as alias2 ON (1 ) ) AS table2   ON ( table1.pk IN ( SELECT t2.pk  FROM t1  LEFT JOIN t2 ON (1 ) ) )", packet_length=200, blocking=true)
          at /home/ppandith/wl-39014/sql/sql_parse.cc:1898
      #31 do_command (thd=, blocking=true) at /home/ppandith/wl-39014/sql/sql_parse.cc:1432
      #32 do_handle_one_connection (connect=, put_in_cache=true) at /home/ppandith/wl-39014/sql/sql_connect.cc:1503
      #33 handle_one_connection (arg=) at /home/ppandith/wl-39014/sql/sql_connect.cc:1415
      #34 pfs_spawn_thread (arg=) at /home/ppandith/wl-39014/storage/perfschema/pfs.cc:2198
      #35 start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
      #36 clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              Gosselin Dave Gosselin
              mariadb-pavithrapandith Pavithra Pandith
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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

                  Git Integration

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