summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-06-05 19:16:54 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-06-05 19:16:54 -0300
commitf3e8609960b13d6d3ac57e3c1d8cacc6978e620d (patch)
treea296754126b086c60a003f8b88c4800d1e9fcf07 /sql/sql_class.h
parentd5109c91a2f22d4fb5650ee199dfd4d529f9fc38 (diff)
downloadmariadb-git-f3e8609960b13d6d3ac57e3c1d8cacc6978e620d.tar.gz
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.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index f4d55917b48..ae7f2a51428 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1464,6 +1464,14 @@ public:
{
changed_tables= 0;
savepoints= 0;
+ /*
+ If rm_error is raised, it means that this piece of a distributed
+ transaction has failed and must be rolled back. But the user must
+ rollback it explicitly, so don't start a new distributed XA until
+ then.
+ */
+ if (!xid_state.rm_error)
+ xid_state.xid.null();
#ifdef USING_TRANSACTIONS
free_root(&mem_root,MYF(MY_KEEP_PREALLOC));
#endif