summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2015-03-12 18:15:08 +0400
committerSergey Vojtovich <svoj@mariadb.org>2015-03-12 18:15:08 +0400
commit20e5c37ccfac9d95a2db1f295f211656df1ce160 (patch)
tree6aa8d3fb3b4707857cdc0c9d05f1129b702c6291 /sql/handler.cc
parent190858d996e7dc90e01fe8a5e7daec6af0012b23 (diff)
downloadmariadb-git-bb-mdev7728.tar.gz
MDEV-7728 - Spiral patch 032_mariadb-10.0.15.scale_registering_xid.diffbb-mdev7728
XID cache is now based on lock-free hash. Also fixed lf_hash_destroy() to call alloc destructor. Note that previous implementation had race condition when thread was accessing XA owned by different thread. This new implementation doesn't fix it either.
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc43
1 files changed, 21 insertions, 22 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 12d7ffb2f5e..a45419f95ca 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1931,12 +1931,28 @@ int ha_recover(HASH *commit_list)
so mysql_xa_recover does not filter XID's to ensure uniqueness.
It can be easily fixed later, if necessary.
*/
+
+static my_bool xa_recover_callback(XID_STATE *xs, Protocol *protocol)
+{
+ if (xs->xa_state == XA_PREPARED)
+ {
+ protocol->prepare_for_resend();
+ protocol->store_longlong((longlong) xs->xid.formatID, FALSE);
+ protocol->store_longlong((longlong) xs->xid.gtrid_length, FALSE);
+ protocol->store_longlong((longlong) xs->xid.bqual_length, FALSE);
+ protocol->store(xs->xid.data, xs->xid.gtrid_length + xs->xid.bqual_length,
+ &my_charset_bin);
+ if (protocol->write())
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
bool mysql_xa_recover(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
- int i=0;
- XID_STATE *xs;
DBUG_ENTER("mysql_xa_recover");
field_list.push_back(new Item_int("formatID", 0, MY_INT32_NUM_DECIMAL_DIGITS));
@@ -1948,26 +1964,9 @@ bool mysql_xa_recover(THD *thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
- mysql_mutex_lock(&LOCK_xid_cache);
- while ((xs= (XID_STATE*) my_hash_element(&xid_cache, i++)))
- {
- if (xs->xa_state==XA_PREPARED)
- {
- protocol->prepare_for_resend();
- protocol->store_longlong((longlong)xs->xid.formatID, FALSE);
- protocol->store_longlong((longlong)xs->xid.gtrid_length, FALSE);
- protocol->store_longlong((longlong)xs->xid.bqual_length, FALSE);
- protocol->store(xs->xid.data, xs->xid.gtrid_length+xs->xid.bqual_length,
- &my_charset_bin);
- if (protocol->write())
- {
- mysql_mutex_unlock(&LOCK_xid_cache);
- DBUG_RETURN(1);
- }
- }
- }
-
- mysql_mutex_unlock(&LOCK_xid_cache);
+ if (xid_cache_iterate(thd, (my_hash_walk_action) xa_recover_callback,
+ protocol))
+ DBUG_RETURN(1);
my_eof(thd);
DBUG_RETURN(0);
}