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

Assertion fails in Item_exists_subselect::exists2in_processor upon concurrent 2nd PS execution and DML

    XMLWordPrintable

Details

    Description

      The test case is only provided as a reproducer, don't put it into the regression suite! Create a deterministic one instead.

      For the race condition, the test case uses loop of 10K repetitions. It currently fails for me every time, but it can vary on different machines and builds, try to increase the $run value (or just re-run it several times) if it doesn't fail right away.

      CREATE TABLE t1 (a INT, b VARCHAR(1)) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (1,NULL),(2,'y');
       
      CREATE TABLE t2 (c INT) ENGINE=MyISAM;
      INSERT INTO t2 VALUES (3),(4);
       
      CREATE TABLE t3 (d INT, e VARCHAR(1)) ENGINE=MyISAM;
      INSERT INTO t3 VALUES (5,NULL),(6,'y');
       
      --connect (con1,localhost,root,,)
      SET lock_wait_timeout= 0;
       
      --let $run=10000
      while ($run)
      {
        --connection default
        --send
          UPDATE t3 JOIN t1 SET d = d+1;
        --connection con1
        PREPARE stmt FROM 'UPDATE t1 JOIN t2 SET t1.a = 1 WHERE EXISTS (SELECT 1 FROM t3 WHERE e = t1.b)';
        --error 0,ER_LOCK_WAIT_TIMEOUT
        EXECUTE stmt;
        --error 0,ER_LOCK_WAIT_TIMEOUT
        EXECUTE stmt;
        --connection default
        --reap
        --dec $run
      }
      DROP TABLE t1, t2, t3;
      

      10.5 b138f428ea2d3496a3a5a2212c424f8218547ef1

      mariadbd: /data/bld/10.5-asan/sql/item_subselect.cc:3246: virtual bool Item_exists_subselect::exists2in_processor(void*): Assertion `thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute() || thd->stmt_arena->is_conventional()' failed.
      241013  1:20:22 [ERROR] mysqld got signal 6 ;
       
      #9  0x00007f1ee4053e32 in __GI___assert_fail (assertion=0x557c5ccac0e0 "thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute() || thd->stmt_arena->is_conventional()", file=0x557c5cca8b40 "/data/bld/11.6-asan/sql/item_subselect.cc", line=3338, function=0x557c5ccabe60 "virtual bool Item_exists_subselect::exists2in_processor(void*)") at ./assert/assert.c:101
      #10 0x0000557c5afaf35e in Item_exists_subselect::exists2in_processor (this=0x62d00089d650, opt_arg=0x62c0000f0218) at /data/bld/11.6-asan/sql/item_subselect.cc:3338
      #11 0x0000557c5af92856 in Item_subselect::walk (this=0x62d00089d650, processor=&virtual table offset 1048, walk_subquery=false, argument=0x62c0000f0218) at /data/bld/11.6-asan/sql/item_subselect.cc:782
      #12 0x0000557c5adc5823 in Item_in_optimizer::walk (this=0x62d00089da70, processor=&virtual table offset 1048, walk_subquery=false, arg=0x62c0000f0218) at /data/bld/11.6-asan/sql/item_cmpfunc.cc:1543
      #13 0x0000557c5a46ad5a in JOIN::optimize_inner (this=0x629000276550) at /data/bld/11.6-asan/sql/sql_select.cc:2237
      #14 0x0000557c5a468b4b in JOIN::optimize (this=0x629000276550) at /data/bld/11.6-asan/sql/sql_select.cc:2003
      #15 0x0000557c5a5586e7 in Sql_cmd_dml::execute_inner (this=0x62d00089bbd0, thd=0x62c0000f0218) at /data/bld/11.6-asan/sql/sql_select.cc:34312
      #16 0x0000557c5a7231b0 in Sql_cmd_update::execute_inner (this=0x62d00089bbd0, thd=0x62c0000f0218) at /data/bld/11.6-asan/sql/sql_update.cc:3115
      #17 0x0000557c5a55838c in Sql_cmd_dml::execute (this=0x62d00089bbd0, thd=0x62c0000f0218) at /data/bld/11.6-asan/sql/sql_select.cc:34261
      #18 0x0000557c5a36f1aa in mysql_execute_command (thd=0x62c0000f0218, is_called_from_prepared_stmt=true) at /data/bld/11.6-asan/sql/sql_parse.cc:4403
      #19 0x0000557c5a41b3e6 in Prepared_statement::execute (this=0x619000133d98, expanded_query=0x7f1ed76a15b0, open_cursor=false) at /data/bld/11.6-asan/sql/sql_prepare.cc:5050
      #20 0x0000557c5a416349 in Prepared_statement::execute_loop (this=0x619000133d98, expanded_query=0x7f1ed76a15b0, open_cursor=false, packet=0x0, packet_end=0x0) at /data/bld/11.6-asan/sql/sql_prepare.cc:4427
      #21 0x0000557c5a40f802 in mysql_sql_stmt_execute (thd=0x62c0000f0218) at /data/bld/11.6-asan/sql/sql_prepare.cc:3446
      #22 0x0000557c5a36c833 in mysql_execute_command (thd=0x62c0000f0218, is_called_from_prepared_stmt=false) at /data/bld/11.6-asan/sql/sql_parse.cc:3970
      #23 0x0000557c5a3874f4 in mysql_parse (thd=0x62c0000f0218, rawbuf=0x629000276238 "EXECUTE stmt", length=12, parser_state=0x7f1ed76a29f0) at /data/bld/11.6-asan/sql/sql_parse.cc:7885
      #24 0x0000557c5a35e630 in dispatch_command (command=COM_QUERY, thd=0x62c0000f0218, packet=0x62900026c219 "EXECUTE stmt", packet_length=12, blocking=true) at /data/bld/11.6-asan/sql/sql_parse.cc:1892
      #25 0x0000557c5a35b344 in do_command (thd=0x62c0000f0218, blocking=true) at /data/bld/11.6-asan/sql/sql_parse.cc:1405
      #26 0x0000557c5a848f80 in do_handle_one_connection (connect=0x6080000036b8, put_in_cache=true) at /data/bld/11.6-asan/sql/sql_connect.cc:1448
      #27 0x0000557c5a84893c in handle_one_connection (arg=0x6080000036b8) at /data/bld/11.6-asan/sql/sql_connect.cc:1350
      #28 0x0000557c5b4d286c in pfs_spawn_thread (arg=0x617000005f18) at /data/bld/11.6-asan/storage/perfschema/pfs.cc:2198
      #29 0x00007f1ee40a8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #30 0x00007f1ee412861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      No obvious immediate problem on a non-debug build.

      Attachments

        Activity

          People

            shulga Dmitry Shulga
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.