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

CREATE OR REPLACE with self-referencing CHECK hangs forever, cannot be killed

    XMLWordPrintable

    Details

      Description

      create table t (a int);
      create or replace table t (a int, check(exists (select * from t)));
      

      CREATE OR REPLACE above hangs with the state Closing tables in the process list.
      The stack trace from the still running query:

      10.3 dbe39f14

      Thread 31 (Thread 0x7fe664446700 (LWP 3982519) "mysqld"):
      #0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7fe60401dca8) at ../sysdeps/nptl/futex-internal.h:186
      #1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7fe60401dbf8, cond=0x7fe60401dc80) at pthread_cond_wait.c:508
      #2  __pthread_cond_wait (cond=0x7fe60401dc80, mutex=0x7fe60401dbf8) at pthread_cond_wait.c:638
      #3  0x0000565170941346 in safe_cond_wait (cond=0x7fe60401dc80, mp=0x7fe60401dbd0, file=0x565170a439f0 "/data/src/10.3/include/mysql/psi/mysql_thread.h", line=1185) at /data/src/10.3/mysys/thr_mutex.c:492
      #4  0x000056516ffec3d3 in inline_mysql_cond_wait (that=0x7fe60401dc80, mutex=0x7fe60401dbd0, src_file=0x565170a43b58 "/data/src/10.3/sql/table_cache.cc", src_line=1178) at /data/src/10.3/include/mysql/psi/mysql_thread.h:1185
      #5  0x000056516ffefbab in tdc_remove_table (thd=0x7fe604000d90, remove_type=TDC_RT_REMOVE_ALL, db=0x7fe604011db0 "test", table_name=0x7fe604011700 "t", kill_delayed_threads=false) at /data/src/10.3/sql/table_cache.cc:1178
      #6  0x000056516fe7a92f in mysql_rm_table_no_locks (thd=0x7fe604000d90, tables=0x7fe664444030, if_exists=false, drop_temporary=false, drop_view=false, drop_sequence=false, dont_log_query=true, dont_free_locks=true) at /data/src/10.3/sql/sql_table.cc:2517
      #7  0x000056516fe822e2 in create_table_impl (thd=0x7fe604000d90, orig_db=0x7fe604011768, orig_table_name=0x7fe604011778, db=0x7fe604011768, table_name=0x7fe604011778, path=0x7fe664444770 "./test/t", options=..., create_info=0x7fe664444bc0, alter_info=0x7fe664444b00, create_table_mode=0, is_trans=0x7fe6644449ce, key_info=0x7fe664444750, key_count=0x7fe664444744, frm=0x7fe664444760) at /data/src/10.3/sql/sql_table.cc:5027
      #8  0x000056516fe82e0f in mysql_create_table_no_lock (thd=0x7fe604000d90, db=0x7fe604011768, table_name=0x7fe604011778, create_info=0x7fe664444bc0, alter_info=0x7fe664444b00, is_trans=0x7fe6644449ce, create_table_mode=0, table_list=0x7fe604011750) at /data/src/10.3/sql/sql_table.cc:5239
      #9  0x000056516fe8322f in mysql_create_table (thd=0x7fe604000d90, create_table=0x7fe604011750, create_info=0x7fe664444bc0, alter_info=0x7fe664444b00) at /data/src/10.3/sql/sql_table.cc:5334
      #10 0x000056516fe954c7 in Sql_cmd_create_table_like::execute (this=0x7fe604011730, thd=0x7fe604000d90) at /data/src/10.3/sql/sql_table.cc:11451
      #11 0x000056516fdacbc8 in mysql_execute_command (thd=0x7fe604000d90) at /data/src/10.3/sql/sql_parse.cc:6075
      #12 0x000056516fdb21aa in mysql_parse (thd=0x7fe604000d90, rawbuf=0x7fe604011608 "create or replace table t (a int, check(not exists (select * from t)))", length=70, parser_state=0x7fe664445600, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7870
      #13 0x000056516fd9e9df in dispatch_command (command=COM_QUERY, thd=0x7fe604000d90, packet=0x7fe604019981 "create or replace table t (a int, check(not exists (select * from t)))", packet_length=70, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852
      #14 0x000056516fd9d39d in do_command (thd=0x7fe604000d90) at /data/src/10.3/sql/sql_parse.cc:1398
      #15 0x000056516ff1a956 in do_handle_one_connection (connect=0x565172f19130) at /data/src/10.3/sql/sql_connect.cc:1403
      #16 0x000056516ff1a6c1 in handle_one_connection (arg=0x565172f19130) at /data/src/10.3/sql/sql_connect.cc:1308
      #17 0x00007fe67aec6ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #18 0x00007fe67adf6def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Killing the thread doesn't interrupt the query:

      |  9 | root        | localhost:41414 | test | Killed  |  393 | Closing tables           | create or replace table t (a int, check(not exists (select * from t))) |    0.000 |
      

      It further causes a hang upon server shutdown.

      Reproducible on 10.3+, MyISAM and InnoDB, debug and release.

        Attachments

          Activity

            People

            Assignee:
            sanja Oleksandr Byelkin
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.