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

Recursive CTE usage leaks memory when not used in a top level select

    XMLWordPrintable

Details

    • Bug
    • Status: In Testing (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 12.3
    • 12.3
    • Optimizer - CTE
    • None
    • Can result in hang or crash

    Description

      Issue:

      ----------------
      Related to MDEV-37220
      Creating recursive cte with delete/update , followed by shutdown crashes the server

      Memory lost: 100688 bytes in 5 chunks of 1775 total chunks
      mariadbd: /home/ppandith/wl-12/sql/sql_class.cc:1917: virtual THD::~THD(): Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed.
      251210 17:23:35 [ERROR] ./sql/mariadbd got signal 6 ;
      Aborted (core dumped)

      Version used:

      --------------
      bb-12.2-MDEV-38272
      commit 59fd634b0b84b25d15df69b5924a6acedd35400a

      How to repro:

      drop database if exists m1;create database m1;use m1;
      create table t1(a int);
      with recursive cte as (select * from t1 union select a from cte where a <2) delete from cte  where a=10;
              shutdown;
      

      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-12/mysys/stacktrace.c:424
      #4  handle_fatal_signal (sig=6) at /home/ppandith/wl-12/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="status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", 
          file=file@entry="/home/ppandith/wl-12/sql/sql_class.cc", line=line@entry=1917, function=function@entry="virtual THD::~THD()")
          at ./assert/assert.c:96
      #12 __assert_fail (assertion="status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", 
          file="/home/ppandith/wl-12/sql/sql_class.cc", line=1917, function="virtual THD::~THD()") at ./assert/assert.c:105
      #13 THD::~THD (this=, __in_chrg=<optimized out>) at /home/ppandith/wl-12/sql/sql_class.cc:1917
      #14 THD::~THD (this=, __in_chrg=<optimized out>) at /home/ppandith/wl-12/sql/sql_class.cc:1930
      #15 do_handle_one_connection (connect=, put_in_cache=true) at /home/ppandith/wl-12/sql/sql_connect.cc:1544
      #16 handle_one_connection (arg=) at /home/ppandith/wl-12/sql/sql_connect.cc:1415
      #17 pfs_spawn_thread (arg=) at /home/ppandith/wl-12/storage/perfschema/pfs.cc:2198
      #18 start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
      #19 clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Activity

          People

            mariadb-pavithrapandith Pavithra Pandith
            mariadb-pavithrapandith Pavithra Pandith
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.