MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:May 12 2009 11:55am
Subject:bzr commit into mysql-5.1-bugteam branch (davi:2874) Bug#44672
View as plain text  
# At a local mysql-5.1-bugteam repository of davi

 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.

    modified:
      mysql-test/r/xa.result
      mysql-test/t/xa.test
      sql/handler.cc
=== modified file 'mysql-test/r/xa.result'
--- a/mysql-test/r/xa.result	2008-10-23 20:56:03 +0000
+++ b/mysql-test/r/xa.result	2009-05-12 11:55:11 +0000
@@ -75,3 +75,9 @@ xa rollback 'a','c';
 xa start 'a','c';
 drop table t1;
 End of 5.0 tests
+xa start 'a';
+xa end 'a';
+xa rollback 'a';
+xa start 'a';
+xa end 'a';
+xa rollback 'a';

=== modified file 'mysql-test/t/xa.test'
--- a/mysql-test/t/xa.test	2009-03-03 20:34:18 +0000
+++ b/mysql-test/t/xa.test	2009-05-12 11:55:11 +0000
@@ -124,6 +124,17 @@ drop table t1;
 
 --echo End of 5.0 tests
 
+#
+# Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null()
+#
+
+xa start 'a';
+xa end 'a';
+xa rollback 'a';
+xa start 'a';
+xa end 'a';
+xa rollback 'a';
+
 # Wait till all disconnects are completed
 --source include/wait_until_count_sessions.inc
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2009-03-27 09:34:24 +0000
+++ b/sql/handler.cc	2009-05-12 11:55:11 +0000
@@ -1193,6 +1193,8 @@ end:
       or ha_rollback_trans().
     */
     thd->transaction.cleanup();
+    if (is_real_trans)
+      thd->transaction.xid_state.xid.null();
   }
 #endif /* USING_TRANSACTIONS */
   DBUG_RETURN(error);
@@ -1294,16 +1296,16 @@ int ha_rollback_trans(THD *thd, bool all
     }
     trans->ha_list= 0;
     trans->no_2pc=0;
-    if (is_real_trans)
-    {
-      if (thd->transaction_rollback_request)
-        thd->transaction.xid_state.rm_error= thd->main_da.sql_errno();
-      else
-        thd->transaction.xid_state.xid.null();
-    }
     if (all)
       thd->variables.tx_isolation=thd->session_tx_isolation;
   }
+  if (is_real_trans)
+  {
+    if (thd->transaction_rollback_request)
+      thd->transaction.xid_state.rm_error= thd->main_da.sql_errno();
+    else
+      thd->transaction.xid_state.xid.null();
+  }
   /* Always cleanup. Even if there nht==0. There may be savepoints. */
   if (all)
     thd->transaction.cleanup();


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20090512115511-g6py5a2wask71wdj.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (davi:2874) Bug#44672Davi Arnaut12 May
  • Re: bzr commit into mysql-5.1-bugteam branch (davi:2874) Bug#44672Sergei Golubchik19 May
    • Re: bzr commit into mysql-5.1-bugteam branch (davi:2874) Bug#44672Davi Arnaut19 May
      • Re: bzr commit into mysql-5.1-bugteam branch (davi:2874) Bug#44672Sergei Golubchik19 May