List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:February 14 2011 2:17pm
Subject:bzr push into mysql-5.5 branch (jon.hauglid:3323 to 3324) Bug#11766788
View as plain text  
 3324 Jon Olav Hauglid	2011-02-14
      Bug #11766788 (former bug 59986)
      Assert in Diagnostics_area::set_ok_status() for XA COMMIT
      
      This assert was triggered if XA COMMIT was issued when an XA transaction
      already had encountered an error (e.g. a deadlock) which required
      the XA transaction to be rolled back.
      
      In general, the assert is triggered if a statement tries to send OK to
      the client when an error has already been reported. It was triggered
      in this case because the trans_xa_commit() function first reported an
      error, then rolled back the transaction and finally returned FALSE,
      indicating success. Since trans_xa_commit() reported success,
      mysql_execute_command() tried to report OK, triggering the assert.
      
      This patch fixes the problem by fixing trans_xa_commit() to return TRUE
      if it encounters an error that requires rollback, even if the rollback
      itself is successful.
      
      Test case added to xa.test.

    modified:
      mysql-test/r/xa.result
      mysql-test/t/xa.test
      sql/transaction.cc
 3323 Georgi Kodinov	2011-02-11 [merge]
      bumped up the version to 5.1.11

    modified:
      VERSION
=== modified file 'mysql-test/r/xa.result'
--- a/mysql-test/r/xa.result	2010-09-13 11:31:22 +0000
+++ b/mysql-test/r/xa.result	2011-02-14 13:16:31 +0000
@@ -142,3 +142,27 @@ XA PREPARE 'x';
 XA PREPARE 'x';
 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
 XA ROLLBACK 'x';
+#
+# Bug#59986 Assert in Diagnostics_area::set_ok_status() for XA COMMIT
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a)) engine=InnoDB;
+INSERT INTO t1 VALUES (1, 1), (2, 2);
+# Connection con1
+XA START 'a';
+UPDATE t1 SET b= 3 WHERE a=1;
+# Connection default
+XA START 'b';
+UPDATE t1 SET b=4 WHERE a=2;
+# Sending:
+UPDATE t1 SET b=5 WHERE a=1;
+# Connection con1
+UPDATE t1 SET b=6 WHERE a=2;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+XA COMMIT 'a';
+ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
+# Connection default
+# Reaping: UPDATE t1 SET b=5 WHERE a=1
+XA END 'b';
+XA ROLLBACK 'b';
+DROP TABLE t1;

=== modified file 'mysql-test/t/xa.test'
--- a/mysql-test/t/xa.test	2010-09-13 11:31:22 +0000
+++ b/mysql-test/t/xa.test	2011-02-14 13:16:31 +0000
@@ -245,6 +245,48 @@ XA PREPARE 'x';
 XA ROLLBACK 'x';
 
 
+--echo #
+--echo # Bug#59986 Assert in Diagnostics_area::set_ok_status() for XA COMMIT
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a)) engine=InnoDB;
+INSERT INTO t1 VALUES (1, 1), (2, 2);
+
+--echo # Connection con1
+connect (con1, localhost, root);
+XA START 'a';
+UPDATE t1 SET b= 3 WHERE a=1;
+
+--echo # Connection default
+connection default;
+XA START 'b';
+UPDATE t1 SET b=4 WHERE a=2;
+--echo # Sending:
+--send UPDATE t1 SET b=5 WHERE a=1
+
+--echo # Connection con1
+connection con1;
+--sleep 1
+--error ER_LOCK_DEADLOCK
+UPDATE t1 SET b=6 WHERE a=2;
+# This used to trigger the assert
+--error ER_XA_RBDEADLOCK
+XA COMMIT 'a';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: UPDATE t1 SET b=5 WHERE a=1
+--reap
+XA END 'b';
+XA ROLLBACK 'b';
+DROP TABLE t1;
+disconnect con1;
+
+
 # Wait till all disconnects are completed
 --source include/wait_until_count_sessions.inc
 

=== modified file 'sql/transaction.cc'
--- a/sql/transaction.cc	2010-11-11 17:11:05 +0000
+++ b/sql/transaction.cc	2011-02-14 13:16:31 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Sun/MySQL
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -635,8 +635,9 @@ bool trans_xa_commit(THD *thd)
 
   if (xa_trans_rolled_back(&thd->transaction.xid_state))
   {
-    if ((res= test(ha_rollback_trans(thd, TRUE))))
+    if (ha_rollback_trans(thd, TRUE))
       my_error(ER_XAER_RMERR, MYF(0));
+    res= thd->is_error();
   }
   else if (xa_state == XA_IDLE && thd->lex->xa_opt == XA_ONE_PHASE)
   {

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5 branch (jon.hauglid:3323 to 3324) Bug#11766788Jon Olav Hauglid14 Feb