List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:March 4 2010 2:55pm
Subject:bzr commit into mysql-5.0-bugteam branch (svoj:2847) Bug#51342
View as plain text  
#At file:///home/svoj/devel/bzr-mysql/mysql-5.0-bugteam-bug51342/ based on revid:joro@stripped

 2847 Sergey Vojtovich	2010-03-04
      BUG#51342 - more xid crashing
      
      SET autocommit=1 while XA transaction is active may
      cause various side effects, including memory corruption
      and server crash.
      
      The problem is that SET autocommit=1 and further queries
      attempt to commit local transaction, whereas XA transaction
      is still active.
      
      As local and XA transactions are mutually exclusive, this
      patch forbids enabling autocommit mode while XA transaction
      is active.
     @ mysql-test/r/xa.result
        A test case for BUG#51342.
     @ mysql-test/t/xa.test
        A test case for BUG#51342.
     @ sql/set_var.cc
        Forbid enabling autocommit mode while XA transaction is
        active.

    modified:
      mysql-test/r/xa.result
      mysql-test/t/xa.test
      sql/set_var.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	2010-03-04 14:54:47 +0000
@@ -74,4 +74,17 @@ ERROR XA102: XA_RBDEADLOCK: Transaction 
 xa rollback 'a','c';
 xa start 'a','c';
 drop table t1;
+#
+# BUG#51342 - more xid crashing
+#
+CREATE TABLE t1(a INT) ENGINE=InnoDB;
+XA START 'x';
+SET SESSION autocommit=0;
+INSERT INTO t1 VALUES(1);
+SET SESSION autocommit=1;
+ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
+INSERT INTO t1 VALUES(1);
+XA END 'x';
+XA COMMIT 'x' ONE PHASE;
+DROP TABLE t1;
 End of 5.0 tests

=== 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	2010-03-04 14:54:47 +0000
@@ -122,6 +122,20 @@ xa start 'a','c';
 --connection default
 drop table t1;
 
+--echo #
+--echo # BUG#51342 - more xid crashing
+--echo #
+CREATE TABLE t1(a INT) ENGINE=InnoDB;
+XA START 'x';
+SET SESSION autocommit=0;
+INSERT INTO t1 VALUES(1);
+--error ER_XAER_RMFAIL
+SET SESSION autocommit=1;
+INSERT INTO t1 VALUES(1);
+XA END 'x';
+XA COMMIT 'x' ONE PHASE;
+DROP TABLE t1;
+
 --echo End of 5.0 tests
 
 # Wait till all disconnects are completed

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2009-12-17 11:25:50 +0000
+++ b/sql/set_var.cc	2010-03-04 14:54:47 +0000
@@ -3065,6 +3065,12 @@ static bool set_option_autocommit(THD *t
     if ((org_options & OPTION_NOT_AUTOCOMMIT))
     {
       /* We changed to auto_commit mode */
+      if (thd->transaction.xid_state.xa_state != XA_NOTR)
+      {
+        my_error(ER_XAER_RMFAIL, MYF(0),
+                 xa_state_names[thd->transaction.xid_state.xa_state]);
+        return 1;
+      }
       thd->options&= ~OPTION_BEGIN;
       thd->transaction.all.modified_non_trans_table= FALSE;
       thd->server_status|= SERVER_STATUS_AUTOCOMMIT;


Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100304145447-p2h1qjftml82sm77.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (svoj:2847) Bug#51342Sergey Vojtovich4 Mar
  • Re: bzr commit into mysql-5.0-bugteam branch (svoj:2847) Bug#51342Davi Arnaut4 Mar
    • Re: bzr commit into mysql-5.0-bugteam branch (svoj:2847) Bug#51342Sergey Vojtovich4 Mar