Bug #44672 Assertion failed: thd->transaction.xid_state.xid.is_null()
Submitted: 5 May 2009 15:20 Modified: 29 Jun 2009 19:46
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S2 (Serious)
Version:5.1.35-debug, 6.0.9-debug OS:Any
Assigned to: Davi Arnaut CPU Architecture:Any
Tags: regression, xa

[5 May 2009 15:20] Shane Bester
Description:
Version: '5.1.34-enterprise-gpl-advanced-debug'  socket: ''  port: 3306  MySQL Enterprise Server - Advanced Edition Debug (GPL)
Assertion failed: thd->transaction.xid_state.xid.is_null(), file .\sql_parse.cc, line 4648

mysqld-debug.exe!my_sigabrt_handler()[mysqld.cc:2013]
mysqld-debug.exe!raise()[winsig.c:590]
mysqld-debug.exe!abort()[abort.c:71]
mysqld-debug.exe!_wassert()[assert.c:212]
mysqld-debug.exe!mysql_execute_command()[sql_parse.cc:4648]
mysqld-debug.exe!mysql_parse()[sql_parse.cc:5902]
mysqld-debug.exe!dispatch_command()[sql_parse.cc:1216]
mysqld-debug.exe!do_command()[sql_parse.cc:857]
mysqld-debug.exe!handle_one_connection()[sql_connect.cc:1115]
mysqld-debug.exe!pthread_start()[my_winthread.c:85]
mysqld-debug.exe!_callthreadstart()[thread.c:293]
mysqld-debug.exe!_threadstart()[thread.c:277]
kernel32.dll!FlsSetValue()
t some variables.
s may be invalid and cause the dump to abort...
t 05D730F0=xa start 'xid1'

How to repeat:
xa start 'xid1';
xa end 'xid1';
xa rollback 'xid1';
xa start 'xid1';
[5 May 2009 15:33] Valeriy Kravchuk
Verified just as described with recent 5.1.35 from bzr on Mac OS X.
[11 May 2009 8:22] MySQL Verification Team
not a dos vector, nor required to have it 'private'.  debug assertion affect debug binary only.  nobody runs debug binaries in production.
[12 May 2009 11:55] 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/73812

2874 Davi Arnaut	2009-05-12
      Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null()
      
      The problem is that when a optimization of read-only transactions
      (bypass 2-phase commit) was implemented, it removed the code that
      reseted the XID once a transaction wasn't active anymore:
      
      sql/sql_parse.cc:
      
      -  bzero(&thd->transaction.stmt, sizeof(thd->transaction.stmt));
      -  if (!thd->active_transaction())
      -    thd->transaction.xid_state.xid.null();
      +  thd->transaction.stmt.reset();
      
      This mostly worked fine as the transaction commit and rollback
      functions (in handler.cc) reset the XID once the transaction is
      ended. But those functions wouldn't reset the XID in case of
      a empty transaction, leading to a assertion when a new starting
      a new XA transaction.
      
      The solution is to ensure that the XID state is reset when empty
      transactions are ended (by either commit or rollback).
     @ mysql-test/r/xa.result
        Add test case result for Bug#44672
     @ mysql-test/t/xa.test
        Add test case for Bug#44672
     @ sql/handler.cc
        Reset the XID even for empty transactions.
[25 May 2009 20:40] 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/74915

2911 Davi Arnaut	2009-05-25
      Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null()
      
      The problem is that when a optimization of read-only transactions
      (bypass 2-phase commit) was implemented, it removed the code that
      reseted the XID once a transaction wasn't active anymore:
      
      sql/sql_parse.cc:
      
      -  bzero(&thd->transaction.stmt, sizeof(thd->transaction.stmt));
      -  if (!thd->active_transaction())
      -    thd->transaction.xid_state.xid.null();
      +  thd->transaction.stmt.reset();
      
      This mostly worked fine as the transaction commit and rollback
      functions (in handler.cc) reset the XID once the transaction is
      ended. But those functions wouldn't reset the XID in case of
      a empty transaction, leading to a assertion when a new starting
      a new XA transaction.
      
      The solution is to ensure that the XID state is reset when empty
      transactions are ended (by either commit or rollback). This is
      achieved by reorganizing the code so that the transaction cleanup
      routine is invoked whenever a transaction is ended.
     @ mysql-test/r/xa.result
        Add test case result for Bug#44672
     @ mysql-test/t/xa.test
        Add test case for Bug#44672
     @ sql/handler.cc
        Invoke transaction cleanup function whenever a transaction is
        ended. Move XID state reset logic to the transaction cleanup
        function.
     @ sql/sql_class.h
        Add XID state reset logic.
[5 Jun 2009 21:43] 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/75755

2935 Davi Arnaut	2009-06-05
      Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null()
      
      The problem is that when a optimization of read-only transactions
      (bypass 2-phase commit) was implemented, it removed the code that
      reseted the XID once a transaction wasn't active anymore:
      
      sql/sql_parse.cc:
      
      -  bzero(&thd->transaction.stmt, sizeof(thd->transaction.stmt));
      -  if (!thd->active_transaction())
      -    thd->transaction.xid_state.xid.null();
      +  thd->transaction.stmt.reset();
      
      This mostly worked fine as the transaction commit and rollback
      functions (in handler.cc) reset the XID once the transaction is
      ended. But those functions wouldn't reset the XID in case of
      a empty transaction, leading to a assertion when a new starting
      a new XA transaction.
      
      The solution is to ensure that the XID state is reset when empty
      transactions are ended (by either commit or rollback). This is
      achieved by reorganizing the code so that the transaction cleanup
      routine is invoked whenever a transaction is ended.
     @ mysql-test/r/xa.result
        Add test case result for Bug#44672
     @ mysql-test/t/xa.test
        Add test case for Bug#44672
     @ sql/handler.cc
        Invoke transaction cleanup function whenever a transaction is
        ended. Move XID state reset logic to the transaction cleanup
        function.
     @ sql/sql_class.h
        Add XID state reset logic.
[5 Jun 2009 22:17] 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/75757

2935 Davi Arnaut	2009-06-05
      Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null()
      
      The problem is that when a optimization of read-only transactions
      (bypass 2-phase commit) was implemented, it removed the code that
      reseted the XID once a transaction wasn't active anymore:
      
      sql/sql_parse.cc:
      
      -  bzero(&thd->transaction.stmt, sizeof(thd->transaction.stmt));
      -  if (!thd->active_transaction())
      -    thd->transaction.xid_state.xid.null();
      +  thd->transaction.stmt.reset();
      
      This mostly worked fine as the transaction commit and rollback
      functions (in handler.cc) reset the XID once the transaction is
      ended. But those functions wouldn't reset the XID in case of
      a empty transaction, leading to a assertion when a new starting
      a new XA transaction.
      
      The solution is to ensure that the XID state is reset when empty
      transactions are ended (by either commit or rollback). This is
      achieved by reorganizing the code so that the transaction cleanup
      routine is invoked whenever a transaction is ended.
     @ mysql-test/r/xa.result
        Add test case result for Bug#44672
     @ mysql-test/t/xa.test
        Add test case for Bug#44672
     @ sql/handler.cc
        Invoke transaction cleanup function whenever a transaction is
        ended. Move XID state reset logic to the transaction cleanup
        function.
     @ sql/sql_class.h
        Add XID state reset logic.
[5 Jun 2009 22:30] Davi Arnaut
Queued to 5.1-bugteam
[16 Jun 2009 11:04] Bugs System
Pushed into 5.1.36 (revid:joro@sun.com-20090616102155-3zhezogudt4uxdyn) (version source revid:azundris@mysql.com-20090606160558-utmxhnb88ur1vcra) (merge vers: 5.1.36) (pib:6)
[17 Jun 2009 19:24] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090616183122-chjzbaa30qopdra9) (version source revid:azundris@mysql.com-20090606160423-aym8s5rn51nmg387) (merge vers: 6.0.12-alpha) (pib:11)
[29 Jun 2009 19:46] Paul Dubois
Noted in 5.1.36, 5.4.4 changelogs.

Code that optimized a read-only XA transaction failed to reset the
XID once the transaction was no longer active.
[12 Aug 2009 22:06] Paul Dubois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[14 Aug 2009 22:57] Paul Dubois
Ignore previous comment about 5.4.2.
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[7 Oct 2009 20:21] Paul Dubois
The 5.4 fix has been pushed to 5.4.2.