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

Atomic DDL: Assertion `query_arg' in THD::binlog_query upon DROP TRIGGER

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: N/A
    • Fix Version/s: N/A
    • Component/s: Triggers
    • Labels:
      None

      Description

      Monty has a patch for it, but it hasn't been pushed anywhere, so I'm filing it to make sure it's not forgotten.

      The test case fails every time for me, but it's still clearly non-deterministic, run with --repeat if it doesn't fail right away.

      --source include/have_log_bin.inc
      CREATE TABLE t1 (a INT);
      CREATE TRIGGER trg AFTER INSERT ON t1 FOR EACH ROW SET @x = 1;
      --connect (con1,localhost,root,,test)
      --send
        DROP TRIGGER trg;
      --connection default
      --error 0,ER_TRG_DOES_NOT_EXIST
      DROP TRIGGER trg;
      # Cleanup
      --connection con1
      --error 0,ER_TRG_DOES_NOT_EXIST
      --reap
      --disconnect con1
      --connection default
      DROP TABLE t1;
      

      bb-10.6-monty 8a94dabc9c

      mysqld: /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_class.cc:7417: int THD::binlog_query(THD::enum_binlog_query_type, const char*, ulong, bool, bool, bool, int): Assertion `query_arg' failed.
      210423  0:17:57 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f776dbea502 in __GI___assert_fail (assertion=0x5652b9fa7b0c "query_arg", file=0x5652b9fa5ee8 "/home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_class.cc", line=7417, function=0x5652b9fa9f00 <THD::binlog_query(THD::enum_binlog_query_type, char const*, unsigned long, bool, bool, bool, int)::__PRETTY_FUNCTION__> "int THD::binlog_query(THD::enum_binlog_query_type, const char*, ulong, bool, bool, bool, int)") at assert.c:101
      #8  0x00005652b91a7faf in THD::binlog_query (this=0x7f771c000d78, qtype=THD::STMT_QUERY_TYPE, query_arg=0x0, query_len=0, is_trans=false, direct=false, suppress_use=false, errcode=0) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_class.cc:7417
      #9  0x00005652b9304f05 in write_bin_log (thd=0x7f771c000d78, clear_error=true, query=0x0, query_length=0, is_trans=false) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_table.cc:893
      #10 0x00005652b932b9dc in mysql_create_or_drop_trigger (thd=0x7f771c000d78, tables=0x7f771c017f28, create=false) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_trigger.cc:666
      #11 0x00005652b921fca0 in mysql_execute_command (thd=0x7f771c000d78) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_parse.cc:5819
      #12 0x00005652b9226785 in mysql_parse (thd=0x7f771c000d78, rawbuf=0x7f771c017db0 "DROP /* QNO 140 CON_ID 24 */ TRIGGER IF EXISTS trg5", length=51, parser_state=0x7f77680fc510) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_parse.cc:8019
      #13 0x00005652b9212b93 in dispatch_command (command=COM_QUERY, thd=0x7f771c000d78, packet=0x7f771c0782d9 "DROP /* QNO 140 CON_ID 24 */ TRIGGER IF EXISTS trg5", packet_length=51, blocking=true) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_parse.cc:1897
      #14 0x00005652b9211469 in do_command (thd=0x7f771c000d78, blocking=true) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_parse.cc:1406
      #15 0x00005652b93c7bd4 in do_handle_one_connection (connect=0x5652bbf98cb8, put_in_cache=true) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_connect.cc:1410
      #16 0x00005652b93c7936 in handle_one_connection (arg=0x5652bc28d118) at /home/mdbe/atomic_ddl/bb-10.6-monty/sql/sql_connect.cc:1312
      #17 0x00005652b991ab87 in pfs_spawn_thread (arg=0x5652bc2e2d28) at /home/mdbe/atomic_ddl/bb-10.6-monty/storage/perfschema/pfs.cc:2201
      #18 0x00007f776eaf56db in start_thread (arg=0x7f77680fd700) at pthread_create.c:463
      #19 0x00007f776dcdb71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Doesn't fail on current main branches.

      Monty's patch

      diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
      index 1c3b7e16f63..b45bea71d26 100644
      --- a/sql/sql_trigger.cc
      +++ b/sql/sql_trigger.cc
      @@ -413,7 +413,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
         */
         TABLE *table;
         bool result= TRUE;
      -  bool add_if_exists_to_binlog= 0;
      +  bool add_if_exists_to_binlog= 0, action_executed= 0;
         String stmt_query;
         bool lock_upgrade_done= FALSE;
         MDL_ticket *mdl_ticket= NULL;
      @@ -512,7 +512,8 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
             */
             result= FALSE;
             /* Still, we need to log the query ... */
      -      stmt_query.append(thd->query(), thd->query_length());
      +      stmt_query.set(thd->query(), thd->query_length(), system_charset_info);
      +      action_executed= 1;
             goto end;
           }
         }
      @@ -635,6 +636,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
             goto drop_orphan_trn;
           }
         }
      +  action_executed= 1;
       
         close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL);
       
      @@ -653,7 +655,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
         sp_cache_invalidate();
       
       end:
      -  if (!result)
      +  if (!result && action_executed)
         {
           ulonglong save_option_bits= thd->variables.option_bits;
           backup_log_info ddl_log;
      @@ -716,6 +718,8 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
         mysql_file_delete(key_file_trg, trn_path_buff, MYF(0));
         result= thd->is_error();
         add_if_exists_to_binlog= 1;
      +  action_executed= 1;
      +  stmt_query.set(thd->query(), thd->query_length(), system_charset_info);
         goto end;
       }
      

      Doesn't fail with the patch. However, there are two differences between 10.6 and bb-10.6-monty with the patch:

      1) it takes exactly twice longer on bb-10.6-monty with the patch comparing to 10.6. With {{--repeat=100 --mem}, on 10.6 it's

      "Spent 0.530 of 19 seconds"

      and on bb-10.6-monty it's

      "Spent 1.065 of 35 seconds"

      Both debug builds without extra instrumentation;
      2) on 10.6 one DROP works, another DROP fails with ER_TRG_DOES_NOT_EXIST. On bb-10.6-monty with the patch both work (don't fail), one produces a warning

      Warning	4182	Dropped orphan trigger 'trg', originally created for table: 't1'

        Attachments

          Activity

            People

            Assignee:
            monty Michael Widenius
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

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