#At file:///home/marko/innobase/dev/mysql2a/5.1-innodb/ based on revid:marko.makela@stripped4ig6ukwe7zw2
3693 Marko Mäkelä 2011-01-27
Bug#59440 Race condition in XA ROLLBACK and XA COMMIT after server restart
trx_get_trx_by_xid(): Invalidate trx->xid after a successful lookup,
so that subsequent callers will not find the same transaction.
The only callers of trx_get_trx_by_xid() will be invoking
innobase_commit_low() or innobase_rollback_trx(), and those code paths
should not depend on trx->xid.
rb://584 approved by Jimmy Yang
modified:
storage/innobase/include/trx0trx.h
storage/innobase/trx/trx0trx.c
storage/innodb_plugin/ChangeLog
storage/innodb_plugin/include/trx0trx.h
storage/innodb_plugin/trx/trx0trx.c
=== modified file 'storage/innobase/include/trx0trx.h'
--- a/storage/innobase/include/trx0trx.h revid:marko.makela@stripped110125134308-cle24ig6ukwe7zw2
+++ b/storage/innobase/include/trx0trx.h revid:marko.makela@stripped9-rd44cmqewxf2bzp7
@@ -198,8 +198,9 @@ which is in the prepared state */
trx_t *
trx_get_trx_by_xid(
/*===============*/
- /* out: trx or NULL */
- XID* xid); /* in: X/Open XA transaction identification */
+ /* out: trx or NULL;
+ on match, the trx->xid will be invalidated */
+ const XID* xid); /* in: X/Open XA transaction identifier */
/**************************************************************************
If required, flushes the log to disk if we called trx_commit_for_mysql()
with trx->flush_log_later == TRUE. */
=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c revid:marko.makela@strippedukwe7zw2
+++ b/storage/innobase/trx/trx0trx.c revid:marko.makela@stripped
@@ -2041,14 +2041,15 @@ which is in the prepared state */
trx_t*
trx_get_trx_by_xid(
/*===============*/
- /* out: trx or NULL */
- XID* xid) /* in: X/Open XA transaction identification */
+ /* out: trx or NULL;
+ on match, the trx->xid will be invalidated */
+ const XID* xid) /* in: X/Open XA transaction identifier */
{
trx_t* trx;
if (xid == NULL) {
- return (NULL);
+ return(NULL);
}
mutex_enter(&kernel_mutex);
@@ -2061,10 +2062,16 @@ trx_get_trx_by_xid(
of gtrid_lenght+bqual_length bytes should be
the same */
- if (xid->gtrid_length == trx->xid.gtrid_length
+ if (trx->conc_state == TRX_PREPARED
+ && xid->gtrid_length == trx->xid.gtrid_length
&& xid->bqual_length == trx->xid.bqual_length
&& memcmp(xid->data, trx->xid.data,
xid->gtrid_length + xid->bqual_length) == 0) {
+
+ /* Invalidate the XID, so that subsequent calls
+ will not find it. */
+ memset(&trx->xid, 0, sizeof(trx->xid));
+ trx->xid.formatID = -1;
break;
}
@@ -2073,14 +2080,5 @@ trx_get_trx_by_xid(
mutex_exit(&kernel_mutex);
- if (trx) {
- if (trx->conc_state != TRX_PREPARED) {
-
- return(NULL);
- }
-
- return(trx);
- } else {
- return(NULL);
- }
+ return(trx);
}
=== modified file 'storage/innodb_plugin/ChangeLog'
--- a/storage/innodb_plugin/ChangeLog revid:marko.makela@stripped308-cle24ig6ukwe7zw2
+++ b/storage/innodb_plugin/ChangeLog revid:marko.makela@strippedf2bzp7
@@ -1,3 +1,9 @@
+2011-01-27 The InnoDB Team
+
+ * include/trx0trx.h, trx/trx0trx.c:
+ Bug#59440 Race condition in XA ROLLBACK and XA COMMIT
+ after server restart
+
2011-01-25 The InnoDB Team
* row/row0upd.c:
=== modified file 'storage/innodb_plugin/include/trx0trx.h'
--- a/storage/innodb_plugin/include/trx0trx.h revid:marko.makela@stripped
+++ b/storage/innodb_plugin/include/trx0trx.h revid:marko.makela@oracle.com-20110127112729-rd44cmqewxf2bzp7
@@ -214,12 +214,12 @@ trx_recover_for_mysql(
/*******************************************************************//**
This function is used to find one X/Open XA distributed transaction
which is in the prepared state
-@return trx or NULL */
+@return trx or NULL; on match, the trx->xid will be invalidated */
UNIV_INTERN
trx_t *
trx_get_trx_by_xid(
/*===============*/
- XID* xid); /*!< in: X/Open XA transaction identification */
+ const XID* xid); /*!< in: X/Open XA transaction identifier */
/**********************************************************************//**
If required, flushes the log to disk if we called trx_commit_for_mysql()
with trx->flush_log_later == TRUE.
=== modified file 'storage/innodb_plugin/trx/trx0trx.c'
--- a/storage/innodb_plugin/trx/trx0trx.c revid:marko.makela@oracle.com-20110125134308-cle24ig6ukwe7zw2
+++ b/storage/innodb_plugin/trx/trx0trx.c revid:marko.makela@stripped127112729-rd44cmqewxf2bzp7
@@ -2010,18 +2010,18 @@ trx_recover_for_mysql(
/*******************************************************************//**
This function is used to find one X/Open XA distributed transaction
which is in the prepared state
-@return trx or NULL */
+@return trx or NULL; on match, the trx->xid will be invalidated */
UNIV_INTERN
trx_t*
trx_get_trx_by_xid(
/*===============*/
- XID* xid) /*!< in: X/Open XA transaction identification */
+ const XID* xid) /*!< in: X/Open XA transaction identifier */
{
trx_t* trx;
if (xid == NULL) {
- return (NULL);
+ return(NULL);
}
mutex_enter(&kernel_mutex);
@@ -2034,10 +2034,16 @@ trx_get_trx_by_xid(
of gtrid_lenght+bqual_length bytes should be
the same */
- if (xid->gtrid_length == trx->xid.gtrid_length
+ if (trx->conc_state == TRX_PREPARED
+ && xid->gtrid_length == trx->xid.gtrid_length
&& xid->bqual_length == trx->xid.bqual_length
&& memcmp(xid->data, trx->xid.data,
xid->gtrid_length + xid->bqual_length) == 0) {
+
+ /* Invalidate the XID, so that subsequent calls
+ will not find it. */
+ memset(&trx->xid, 0, sizeof(trx->xid));
+ trx->xid.formatID = -1;
break;
}
@@ -2046,14 +2052,5 @@ trx_get_trx_by_xid(
mutex_exit(&kernel_mutex);
- if (trx) {
- if (trx->conc_state != TRX_PREPARED) {
-
- return(NULL);
- }
-
- return(trx);
- } else {
- return(NULL);
- }
+ return(trx);
}
Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110127112729-rd44cmqewxf2bzp7.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-innodb branch (marko.makela:3693) Bug#59440 | marko.makela | 27 Jan |