mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
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:'.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user