Bug #56452 Assertion failed: thd->transaction.stmt.is_empty() || thd->in_sub_stmt
Submitted: 1 Sep 2010 14:09 Modified: 20 Nov 2010 18:02
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S1 (Critical)
Version:5.5.7-m3, 5.6.0-m4-debug, mysql-trunk OS:Any
Assigned to: Magne Mæhre
Tags: regression
Triage: Triaged: D1 (Critical)

[1 Sep 2010 14:09] Shane Bester
Description:
Version: '5.6.0-m4-debug'  socket: ''  port: 3306  MySQL Community Server - Debug (GPL)
Assertion failed: thd->transaction.stmt.is_empty() || thd->in_sub_stmt, file ..\..\mysql-5.6.0-m4\sql\sql_parse.cc, line 2024

my_sigabrt_handler()[my_thr_init.c:519]
raise()[winsig.c:597]
abort()[abort.c:78]
_wassert()[assert.c:163]
mysql_execute_command()[sql_parse.cc:2024]
mysql_parse()[sql_parse.cc:5828]
dispatch_command()[sql_parse.cc:1132]
do_command()[sql_parse.cc:801]
do_handle_one_connection()[sql_connect.cc:1191]
handle_one_connection()[sql_connect.cc:1131]
pthread_start()[my_winthread.c:62]
_callthreadstartex()[threadex.c:348]
_threadstartex()[threadex.c:331]
BaseThreadStart()

How to repeat:
#on debug build:

drop table if exists t1;
create table t1(a int)engine=innodb;
begin ; 
insert into t1 values (1);
rollback work and chain no release; 
select a from t1; 
rollback work and chain no release; 
select a from t1; 
rollback;
[1 Sep 2010 14:12] Valerii Kravchuk
Does NOT happen to me with current mysql-5.5 and current mysql-trunk from bzr on Mac OS X:

macbook-pro:trunk openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.1-m4-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop table if exists t1;
Query OK, 0 rows affected (0.02 sec)

mysql> create table t1(a int)engine=innodb;
Query OK, 0 rows affected (0.11 sec)

mysql> begin ; 
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (1);
Query OK, 1 row affected (0.01 sec)

mysql> rollback work and chain no release; 
Query OK, 0 rows affected (0.00 sec)

mysql> select a from t1; 
Empty set (0.00 sec)

mysql> rollback work and chain no release; 
Query OK, 0 rows affected (0.00 sec)

mysql> select a from t1; 
Empty set (0.00 sec)

mysql> rollback;
Query OK, 0 rows affected (0.00 sec)
[1 Sep 2010 14:30] Shane Bester
hi!

sorry, you need query cache enabled:
--query-cache-type=1 --query-cache-size=10M
[1 Sep 2010 14:48] Valerii Kravchuk
With query cache enabled we have aasertion failure:

macbook-pro:trunk openxs$ bin/mysql -uroot testReading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.1-m4-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop table if exists t1;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t1(a int)engine=innodb;
Query OK, 0 rows affected (0.45 sec)

mysql> begin ; 
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (1);
Query OK, 1 row affected (0.00 sec)

mysql> rollback work and chain no release; 
Query OK, 0 rows affected (0.01 sec)

mysql> select a from t1; 
Empty set (0.00 sec)

mysql> rollback work and chain no release; 
Query OK, 0 rows affected (0.00 sec)

mysql> select a from t1; 
Empty set (0.00 sec)

mysql> rollback;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 100901 17:46:10 mysqld_safe mysqld restarted

mysql> exit
Bye
macbook-pro:trunk openxs$ tail -100 var/macbook-pro.err 
100901 17:11:20 [Warning] One can only use the --user switch if running as root

100901 17:11:20 [Note] Plugin 'FEDERATED' is disabled.
100901 17:11:20 [Note] Plugin 'ndbcluster' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3
100901 17:11:21  InnoDB: highest supported file format is Barracuda.
100901 17:11:21 InnoDB 1.2.0 started; log sequence number 305323983
100901 17:11:21 [ERROR] Native table 'performance_schema'.'THREADS' has the wrong structure
100901 17:11:21 [ERROR] Native table 'performance_schema'.'EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME' has the wrong structure
100901 17:11:21 [Note] Event Scheduler: Loaded 0 events
100901 17:11:21 [Note] /Users/openxs/dbs/trunk/libexec/mysqld: ready for connections.
Version: '5.6.1-m4-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
::index_read(): 0xb077f000 0xb077f000 select a from t1
::index_read(): 0xb077f000 0xb077f000 select a from t1
100901 17:45:34 [Note] Got signal 15 to shutdown mysqld
100901 17:45:34 [Note] /Users/openxs/dbs/trunk/libexec/mysqld: Normal shutdown

100901 17:45:34 [Note] Event Scheduler: Purging the queue. 0 events
100901 17:45:34  InnoDB: Starting shutdown...
100901 17:45:36  InnoDB: Shutdown completed; log sequence number 305328003
100901 17:45:36 [Note] /Users/openxs/dbs/trunk/libexec/mysqld: Shutdown complete

100901 17:45:36 mysqld_safe mysqld from pid file /Users/openxs/dbs/trunk/var/macbook-pro.pid ended
100901 17:45:42 mysqld_safe Starting mysqld daemon with databases from /Users/openxs/dbs/trunk/var
100901 17:45:42 [Warning] Setting lower_case_table_names=2 because file system for /Users/openxs/dbs/trunk/var/ is case insensitive
100901 17:45:42 [Warning] One can only use the --user switch if running as root

100901 17:45:42 [Note] Plugin 'FEDERATED' is disabled.
100901 17:45:42 [Note] Plugin 'ndbcluster' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3
100901 17:45:42  InnoDB: highest supported file format is Barracuda.
100901 17:45:42 InnoDB 1.2.0 started; log sequence number 305328003
100901 17:45:42 [ERROR] Native table 'performance_schema'.'THREADS' has the wrong structure
100901 17:45:42 [ERROR] Native table 'performance_schema'.'EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME' has the wrong structure
100901 17:45:42 [Note] Event Scheduler: Loaded 0 events
100901 17:45:42 [Note] /Users/openxs/dbs/trunk/libexec/mysqld: ready for connections.
Version: '5.6.1-m4-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
::index_read(): 0xb077f000 0xb077f000 select a from t1
Assertion failed: (thd->transaction.stmt.is_empty() || thd->in_sub_stmt), function mysql_execute_command, file sql_parse.cc, line 1891.
100901 17:46:10 - mysqld got signal 6 ;
[1 Sep 2010 14:50] Valerii Kravchuk
Current mysql-5.5 from bzr is also affected:

macbook-pro:5.5 openxs$ bin/mysql -uroot testReading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.7-m3-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop table if exists t1;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t1(a int)engine=innodb;
Query OK, 0 rows affected (0.13 sec)

mysql> begin ; 
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (1);
Query OK, 1 row affected (0.00 sec)

mysql> rollback work and chain no release; 
Query OK, 0 rows affected (0.00 sec)

mysql> select a from t1; 
Empty set (0.00 sec)

mysql> rollback work and chain no release; 
Query OK, 0 rows affected (0.00 sec)

mysql> select a from t1; 
Empty set (0.00 sec)

mysql> rollback;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 100901 17:48:46 mysqld_safe mysqld restarted
[1 Sep 2010 14:51] Valerii Kravchuk
In current mysql-5.1 from bzr debug build everything works as expected, so it is indeed a regression bug.
[10 Sep 2010 21:49] Omer Barnir
triage: setting tag to SR55RC (regression)
[15 Sep 2010 21:48] 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/118338

3138 Magne Mahre	2010-09-15
      Bug#56452 Assertion failed: thd->transaction.stmt.is_empty() || 
                thd->in_sub_stmt
      
      In a precursor patch for Bug#52044 
      (revid:bzr/kostja@sun.com-20100721134332-c9vb0pach19v94wk), a
      number of reorganizations of code was made. In addition some
      assertions were added to ensure the correct transactional state.
      
      The reorganization had a small glitch so statements that was
      active in the query cache was not followed by a
      statement commit/rollback (this code was removed). A section
      in the trans_commit_stmt/trans_rollback_stmt code is to
      clear the thd->transaction.stmt list of affected storage
      engines.  When a new statement is initiated, an assert
      introduced by the 523044 patch checks if this list is cleared.
      When the query cache is accessed, this list may be populated,
      and since it's not committed it will not be cleared.
      
      This fix adds explicit statement commit or rollback for
      statements that is contained in the query cache.
     @ sql/sql_parse.cc
        Ensure that even statements that the query cache provides
        results for, are committed properly.
[6 Oct 2010 9:02] 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/120068

3154 Magne Mahre	2010-10-06
      Bug#56452 Assertion failed: thd->transaction.stmt.is_empty() || 
                thd->in_sub_stmt
            
      In a precursor patch for Bug#52044 
      (revid:bzr/kostja@stripped), a
      number of reorganizations of code was made. In addition some
      assertions were added to ensure the correct transactional state.
            
      The reorganization had a small glitch so statements that was
      active in the query cache was not followed by a
      statement commit/rollback (this code was removed). A section
      in the trans_commit_stmt/trans_rollback_stmt code is to
      clear the thd->transaction.stmt list of affected storage
      engines.  When a new statement is initiated, an assert
      introduced by the 523044 patch checks if this list is cleared.
      When the query cache is accessed, this list may be populated,
      and since it's not committed it will not be cleared.
            
      This fix adds explicit statement commit or rollback for
      statements that is contained in the query cache.
[9 Nov 2010 19:46] Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (merge vers: 5.5.7-rc) (pib:21)
[13 Nov 2010 16:21] 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:35] 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 18:01] Paul Dubois
"I'm not sure if 56452 really warrants a changelog entry in itself.  The
bug was introduced by a patch pushed in August, and the fix came in
September."

I think you're right. This bug would not have appeared in any released version. Thanks.
[20 Nov 2010 18:02] Paul Dubois
Bug did not appear in any released version. No changelog entry needed.