Bug #55930 Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state..
Submitted: 12 Aug 2010 0:33 Modified: 20 Nov 2010 17:41
Reporter: Elena Stepanova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:5.5.6-m3-debug, 5.6.0-m4-debug OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[12 Aug 2010 0:33] Elena Stepanova
Description:
trunk-bugfixing, 5.5-bugfixing

mysqld: mysql-5.6.0-m4/sql/sql_base.cc:1412: void close_thread_tables(THD*): Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' failed.
100809  2:45:56 - mysqld got signal 6 ;

#7  0x000000000056a105 in close_thread_tables (thd=0x2aaab05e4ee0) at mysql-5.6.0-m4/sql/sql_base.cc:1411
#8  0x000000000056d3ed in open_ltable (thd=0x2aaab05e4ee0, table_list=0x2881db0, lock_type=TL_WRITE, lock_flags=0)
    at mysql-5.6.0-m4/sql/sql_base.cc:5264
#9  0x00000000006377d4 in mysql_admin_table (thd=0x2aaab05e4ee0, tables=0x2881db0, check_opt=0x2aaab05e74b0, operator_name=0xb27681 "optimize",
    lock_type=TL_WRITE, open_for_modify=false, no_warnings_for_error=false, extra_open_options=0, prepare_func=0, operator_func=
    (int ( class handler::*)(class THD *,HA_CHECK_OPT *,)) 919947, view_operator_func=0)
    at mysql-5.6.0-m4/sql/sql_table.cc:5219
#10 0x0000000000638370 in mysql_optimize_table (thd=0x2aaab05e4ee0, tables=0x2881db0, check_opt=0x2aaab05e74b0)
    at mysql-5.6.0-m4/sql/sql_table.cc:5378
#11 0x00000000005b50aa in mysql_execute_command (thd=0x2aaab05e4ee0) at mysql-5.6.0-m4/sql/sql_parse.cc:3007
#12 0x00000000005ba9ba in mysql_parse (thd=0x2aaab05e4ee0, rawbuf=0x2881c50 "ALTER TABLE t_celosia_ddl_partitions OPTIMIZE PARTITION p3", length=58,
    parser_state=0x47a97a30) at mysql-5.6.0-m4/sql/sql_parse.cc:5827
#13 0x00000000005bbfe6 in dispatch_command (command=COM_QUERY, thd=0x2aaab05e4ee0, packet=0x2aaaae361881 "", packet_length=58)
    at mysql-5.6.0-m4/sql/sql_parse.cc:1129
#14 0x00000000005bd450 in do_command (thd=0x2aaab05e4ee0) at mysql-5.6.0-m4/sql/sql_parse.cc:801
#15 0x0000000000684c3c in do_handle_one_connection (thd_arg=0x2aaab05e4ee0)
    at mysql-5.6.0-m4/sql/sql_connect.cc:1191
#16 0x0000000000684d05 in handle_one_connection (arg=0x2aaab05e4ee0) at mysql-5.6.0-m4/sql/sql_connect.cc:1130
#17 0x00002b5a1d91f143 in start_thread () from /lib64/libpthread.so.0
#18 0x00002b5a1e0908cd in clone () from /lib64/libc.so.6

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x2881c50 = ALTER TABLE t_celosia_ddl_partitions OPTIMIZE PARTITION p3
thd->thread_id=6085
thd->killed=NOT_KILLED

How to repeat:
No test case yet
[23 Sep 2010 10:30] Jon Olav Hauglid
Also seen when running RQG tests on mysql-5.5-runtime.
[1 Oct 2010 6:34] Jon Olav Hauglid
Also seen when running RQG tests on mysql-5.5-runtime for non-partitioned tables.
Setting bug to Verified and assigning it to myself for further investigation.
[13 Oct 2010 11:53] Jon Olav Hauglid
MTR test case:

--source include/have_debug_sync.inc

CREATE TABLE t1(a INT) engine=InnoDB;
INSERT INTO t1 VALUES (1), (2);

connect (con1, localhost, root);
connect (con2, localhost, root);

connection con1;
SET SESSION lock_wait_timeout= 1;
SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL opti_recreate WAIT_FOR opti_analyze';
--send OPTIMIZE TABLE t1

connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR opti_recreate';
SET DEBUG_SYNC= 'after_lock_tables_takes_lock SIGNAL thrlock WAIT_FOR release_thrlock';
--send INSERT INTO t1 VALUES (3)

connection default;
SET DEBUG_SYNC= 'now WAIT_FOR thrlock';
SET DEBUG_SYNC= 'now SIGNAL opti_analyze';

connection con1;
--reap
SET DEBUG_SYNC= 'now SIGNAL release_thrlock';

connection con2;
--reap

connection default;
disconnect con1;
disconnect con2;
DROP TABLE t1;
[13 Oct 2010 11:55] Jon Olav Hauglid
Bug #57148 was marked as a duplicate of this bug.
[13 Oct 2010 14:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120691

3164 Jon Olav Hauglid	2010-10-13
      Bug #55930 Assertion `thd->transaction.stmt.is_empty() ||
                 thd->in_sub_stmt || (thd->state..
      
      OPTIMIZE TABLE is not directly supported by InnoDB. Instead,
      recreate and analyze of the table is done. After recreate,
      the table is closed and locks are released before the table
      is reopened and locks re-acquired for the analyze phase.
      
      This assertion was triggered if OPTIMIZE TABLE failed to
      acquire thr_lock locks before starting the analyze phase.
      The assertion tests (among other things) that there no
      active statement transaction. However, as part of acquiring
      the thr_lock lock, external_lock() is called for InnoDB
      tables and this causes a statement transaction to be started.
      If thr_multi_lock() later fails (e.g. due to timeout),
      the failure handling code causes this assert to be triggered.
      
      This patch fixes the problem by doing rollback of the
      current statement transaction in case open_ltable (used by
      OPTIMIZE TABLE) fails to acquire thr_lock locks.
      
      Test case added to lock_sync.test.
[13 Oct 2010 14:29] Konstantin Osipov
OK to push.
[13 Oct 2010 14:58] Jon Olav Hauglid
Pushed to mysql-5.5-runtime.
[14 Oct 2010 9:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120755

3165 Jon Olav Hauglid	2010-10-14
      Follow-up for Bug #55930 Assertion `thd->transaction.stmt.is_empty()
                               || thd->in_sub_stmt || (thd->state..
      
      Don't rollback statement transactions if we are in a sub-statement.
      This could for example happen for open_ltable() when opening the
      general log during execution of a stored procedure.
[13 Nov 2010 16:11] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:31] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)
[20 Nov 2010 17:41] Paul DuBois
Noted in 5.5.8 changelog.

OPTIMIZE TABLE for InnoDB tables could raise an assertion.
[16 Dec 2010 22:27] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)