1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

perfschema transaction instrumentation related changes

This commit is contained in:
Sergei Golubchik
2020-02-14 16:38:49 +01:00
parent 6ded554fc2
commit 81cffda2e6
10 changed files with 188 additions and 41 deletions

View File

@@ -19,7 +19,8 @@
#include "mariadb.h"
#include "sql_class.h"
#include "transaction.h"
#include <pfs_transaction_provider.h>
#include <mysql/psi/mysql_transaction.h>
/***************************************************************************
Handling of XA id caching
@@ -425,7 +426,10 @@ bool trans_xa_start(THD *thd)
if (not_equal)
my_error(ER_XAER_NOTA, MYF(0));
else
{
thd->transaction.xid_state.xid_cache_element->xa_state= XA_ACTIVE;
MYSQL_SET_TRANSACTION_XA_STATE(thd->m_transaction_psi, XA_ACTIVE);
}
DBUG_RETURN(not_equal);
}
@@ -440,6 +444,7 @@ bool trans_xa_start(THD *thd)
my_error(ER_XAER_OUTSIDE, MYF(0));
else if (!trans_begin(thd))
{
MYSQL_SET_TRANSACTION_XID(thd->m_transaction_psi, thd->lex->xid, XA_ACTIVE);
if (xid_cache_insert(thd, &thd->transaction.xid_state, thd->lex->xid))
{
trans_rollback(thd);
@@ -474,7 +479,10 @@ bool trans_xa_end(THD *thd)
else if (!thd->transaction.xid_state.xid_cache_element->xid.eq(thd->lex->xid))
my_error(ER_XAER_NOTA, MYF(0));
else if (!xa_trans_rolled_back(thd->transaction.xid_state.xid_cache_element))
{
thd->transaction.xid_state.xid_cache_element->xa_state= XA_IDLE;
MYSQL_SET_TRANSACTION_XA_STATE(thd->m_transaction_psi, XA_IDLE);
}
DBUG_RETURN(thd->is_error() ||
thd->transaction.xid_state.xid_cache_element->xa_state != XA_IDLE);
@@ -505,7 +513,10 @@ bool trans_xa_prepare(THD *thd)
my_error(ER_XA_RBROLLBACK, MYF(0));
}
else
{
thd->transaction.xid_state.xid_cache_element->xa_state= XA_PREPARED;
MYSQL_SET_TRANSACTION_XA_STATE(thd->m_transaction_psi, XA_PREPARED);
}
DBUG_RETURN(thd->is_error() ||
thd->transaction.xid_state.xid_cache_element->xa_state != XA_PREPARED);
@@ -608,6 +619,16 @@ bool trans_xa_commit(THD *thd)
res= MY_TEST(ha_commit_one_phase(thd, 1));
if (res)
my_error(ER_XAER_RMERR, MYF(0));
else
{
/*
Since we don't call ha_commit_trans() for prepared transactions,
we need to explicitly mark the transaction as committed.
*/
MYSQL_COMMIT_TRANSACTION(thd->m_transaction_psi);
}
thd->m_transaction_psi= NULL;
}
}
else
@@ -624,7 +645,8 @@ bool trans_xa_commit(THD *thd)
xid_cache_delete(thd, &thd->transaction.xid_state);
trans_track_end_trx(thd);
/* The transaction should be marked as complete in P_S. */
DBUG_ASSERT(thd->m_transaction_psi == NULL || res);
DBUG_RETURN(res);
}