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

Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' fails in open_normal_and_derived_tables upon killing connection running SETVAL

    XMLWordPrintable

Details

    Description

      Note: It is possibly related to MDEV-16929, which is also about the assertion upon killing a sequence operation, but this time the failure happens in a different place with a different stack trace, so I'm filing it separately just in case.

      Note: the test case is non-deterministic, run with --repeat=N. It currently always fails for me within ~5 attempts, but it can vary on different machines and builds.

      --source include/have_innodb.inc
       
      CREATE SEQUENCE s ENGINE=InnoDB;
      FLUSH TABLES WITH READ LOCK;
       
      --connect (con1,localhost,root,,)
      --let $conid= `SELECT CONNECTION_ID()`
      --send
        PREPARE stmt FROM 'SELECT SETVAL(s, 0)';
       
      --connection default
      --eval KILL $conid
      UNLOCK TABLES;
      DROP SEQUENCE s;
      

      10.3 5b2fa078

      mysqld: /data/src/10.3/sql/sql_base.cc:5124: bool open_normal_and_derived_tables(THD*, TABLE_LIST*, uint, uint): Assertion `thd->transaction.stmt.is_empty() || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' failed.
      191004 15:48:12 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f09e5efbf12 in __GI___assert_fail (assertion=0x55dff4817360 "thd->transaction.stmt.is_empty() || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)", file=0x55dff4816478 "/data/src/10.3/sql/sql_base.cc", line=5124, function=0x55dff4818dc0 <open_normal_and_derived_tables(THD*, TABLE_LIST*, unsigned int, unsigned int)::__PRETTY_FUNCTION__> "bool open_normal_and_derived_tables(THD*, TABLE_LIST*, uint, uint)") at assert.c:101
      #8  0x000055dff3b459b0 in open_normal_and_derived_tables (thd=0x7f098c000b00, tables=0x7f098c01b760, flags=512, dt_phases=35) at /data/src/10.3/sql/sql_base.cc:5123
      #9  0x000055dff3bf9cac in mysql_test_select (stmt=0x7f098c013070, tables=0x7f098c01b760) at /data/src/10.3/sql/sql_prepare.cc:1534
      #10 0x000055dff3bfb932 in check_prepared_statement (stmt=0x7f098c013070) at /data/src/10.3/sql/sql_prepare.cc:2346
      #11 0x000055dff3bffb55 in Prepared_statement::prepare (this=0x7f098c013070, packet=0x7f098c0136e0 "SELECT SETVAL(s, 0)", packet_len=19) at /data/src/10.3/sql/sql_prepare.cc:4028
      #12 0x000055dff3bfc80d in mysql_sql_stmt_prepare (thd=0x7f098c000b00) at /data/src/10.3/sql/sql_prepare.cc:2843
      #13 0x000055dff3bd541f in mysql_execute_command (thd=0x7f098c000b00) at /data/src/10.3/sql/sql_parse.cc:3827
      #14 0x000055dff3be2cc3 in mysql_parse (thd=0x7f098c000b00, rawbuf=0x7f098c013618 "PREPARE stmt FROM 'SELECT SETVAL(s, 0)'", length=39, parser_state=0x7f09e00af5e0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7829
      #15 0x000055dff3bcf8fd in dispatch_command (command=COM_QUERY, thd=0x7f098c000b00, packet=0x7f098c008c71 "PREPARE stmt FROM 'SELECT SETVAL(s, 0)'", packet_length=39, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1855
      #16 0x000055dff3bce245 in do_command (thd=0x7f098c000b00) at /data/src/10.3/sql/sql_parse.cc:1400
      #17 0x000055dff3d44c18 in do_handle_one_connection (connect=0x55dff6ecfbd0) at /data/src/10.3/sql/sql_connect.cc:1403
      #18 0x000055dff3d4497a in handle_one_connection (arg=0x55dff6ecfbd0) at /data/src/10.3/sql/sql_connect.cc:1308
      #19 0x000055dff46ef86e in pfs_spawn_thread (arg=0x55dff6b65e60) at /data/src/10.3/storage/perfschema/pfs.cc:1862
      #20 0x00007f09e7a714a4 in start_thread (arg=0x7f09e00b0700) at pthread_create.c:456
      #21 0x00007f09e5fb8d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
       
      Query (0x7f098c01b680): SELECT SETVAL(s, 0)
      Connection ID (thread ID): 10
      Status: KILL_CONNECTION
      

      Alternative test case, with BACKUP stages instead of FTWRL:

      --source include/have_innodb.inc
       
      CREATE SEQUENCE s ENGINE=InnoDB;
      BACKUP STAGE START;
      BACKUP STAGE BLOCK_COMMIT;
       
      --connect (con1,localhost,root,,)
      --let $conid= `SELECT CONNECTION_ID()`
      --send
        PREPARE stmt FROM 'SELECT SETVAL(s, 0)';
       
      --connection default
      --eval KILL $conid
      BACKUP STAGE END;
      DROP SEQUENCE s;
      

      10.4 eb0a10b0

      mysqld: /data/src/10.4/sql/sql_base.cc:5309: bool open_normal_and_derived_tables(THD*, TABLE_LIST*, uint, uint): Assertion `thd->transaction.stmt.is_empty() || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' failed.
      191004 15:50:13 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f0721584f12 in __GI___assert_fail (assertion=0x5583b2621340 "thd->transaction.stmt.is_empty() || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)", file=0x5583b2620370 "/data/src/10.4/sql/sql_base.cc", line=5309, function=0x5583b2622ec0 <open_normal_and_derived_tables(THD*, TABLE_LIST*, unsigned int, unsigned int)::__PRETTY_FUNCTION__> "bool open_normal_and_derived_tables(THD*, TABLE_LIST*, uint, uint)") at assert.c:101
      #8  0x00005583b18ac33e in open_normal_and_derived_tables (thd=0x7f06cc000b00, tables=0x7f06cc01c6c0, flags=512, dt_phases=35) at /data/src/10.4/sql/sql_base.cc:5308
      #9  0x00005583b196fa9e in mysql_test_select (stmt=0x7f06cc01a200, tables=0x7f06cc01c6c0) at /data/src/10.4/sql/sql_prepare.cc:1535
      #10 0x00005583b197172f in check_prepared_statement (stmt=0x7f06cc01a200) at /data/src/10.4/sql/sql_prepare.cc:2360
      #11 0x00005583b19759f1 in Prepared_statement::prepare (this=0x7f06cc01a200, packet=0x7f06cc011e20 "SELECT SETVAL(s, 0)", packet_len=19) at /data/src/10.4/sql/sql_prepare.cc:4048
      #12 0x00005583b1972669 in mysql_sql_stmt_prepare (thd=0x7f06cc000b00) at /data/src/10.4/sql/sql_prepare.cc:2859
      #13 0x00005583b1949779 in mysql_execute_command (thd=0x7f06cc000b00) at /data/src/10.4/sql/sql_parse.cc:3905
      #14 0x00005583b195817f in mysql_parse (thd=0x7f06cc000b00, rawbuf=0x7f06cc011d68 "PREPARE stmt FROM 'SELECT SETVAL(s, 0)'", length=39, parser_state=0x7f07168e5170, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7912
      #15 0x00005583b1943412 in dispatch_command (command=COM_QUERY, thd=0x7f06cc000b00, packet=0x7f06cc008331 "PREPARE stmt FROM 'SELECT SETVAL(s, 0)'", packet_length=39, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1841
      #16 0x00005583b1941a9f in do_command (thd=0x7f06cc000b00) at /data/src/10.4/sql/sql_parse.cc:1359
      #17 0x00005583b1ac9153 in do_handle_one_connection (connect=0x5583b5f69250) at /data/src/10.4/sql/sql_connect.cc:1412
      #18 0x00005583b1ac8ea2 in handle_one_connection (arg=0x5583b5f69250) at /data/src/10.4/sql/sql_connect.cc:1316
      #19 0x00005583b24c816f in pfs_spawn_thread (arg=0x5583b5edbd40) at /data/src/10.4/storage/perfschema/pfs.cc:1862
      #20 0x00007f07230fa4a4 in start_thread (arg=0x7f07168e6700) at pthread_create.c:456
      #21 0x00007f0721641d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
      

      Also reproducible on 10.5.
      Couldn't reproduce without PREPARE.
      No obvious effect on a non-debug build.

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.