summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorDmitry Shulga <Dmitry.Shulga@Sun.COM>2010-06-29 16:32:03 +0700
committerDmitry Shulga <Dmitry.Shulga@Sun.COM>2010-06-29 16:32:03 +0700
commit7ccbf9b817b47d0393fe66bda6f6013ec24486ba (patch)
treee7719a7a52654d8d2e904b0df66123387fdf3e81 /sql/sql_class.cc
parent836f7fcfc6ad843b11b551a8b9715422d38f2356 (diff)
downloadmariadb-git-7ccbf9b817b47d0393fe66bda6f6013ec24486ba.tar.gz
Fixed bug #51855. Race condition in XA START. If several threads
concurrently execute the statement XA START 'x', then mysqld server could crash. sql/sql_class.cc: xid_cache_insert: added checking for element in cache before insert it, return TRUE if such element already exists. sql/sql_parse.cc: mysql_execute_command modified: * sequence of calls to xid_cache_search(..)/xid_cache_insert(...) replaced by call to xid_cache_insert(...) in alternative 'case SQLCOM_XA_START:' * added comment to alternative 'case SQLCOM_XA_COMMIT:'.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 93aa6a8268c..99792f2b262 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -3365,9 +3365,13 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state)
bool xid_cache_insert(XID_STATE *xid_state)
{
pthread_mutex_lock(&LOCK_xid_cache);
- DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(),
- xid_state->xid.key_length())==0);
- my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state);
+ if (hash_search(&xid_cache, xid_state->xid.key(), xid_state->xid.key_length()))
+ {
+ pthread_mutex_unlock(&LOCK_xid_cache);
+ my_error(ER_XAER_DUPID, MYF(0));
+ return TRUE;
+ }
+ my_bool res= my_hash_insert(&xid_cache, (uchar*)xid_state);
pthread_mutex_unlock(&LOCK_xid_cache);
return res;
}