summaryrefslogtreecommitdiff
path: root/storage/tokudb/hatoku_hton.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-05-10 13:01:42 +0200
committerSergei Golubchik <serg@mariadb.org>2018-05-10 13:01:42 +0200
commit9b1824dcd2564c803e58d02ac63b49ec68bd60d2 (patch)
treebeef3faf3e0e6b8264014a0cfb735d4a32be6cbc /storage/tokudb/hatoku_hton.cc
parent92a13148e80c30422ae5460032169cbe1946fa6d (diff)
parentff579bc814551026a3271fac274f560cef3f523f (diff)
downloadmariadb-git-9b1824dcd2564c803e58d02ac63b49ec68bd60d2.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'storage/tokudb/hatoku_hton.cc')
-rw-r--r--storage/tokudb/hatoku_hton.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc
index 75f4a5a70f0..2b138bdeb79 100644
--- a/storage/tokudb/hatoku_hton.cc
+++ b/storage/tokudb/hatoku_hton.cc
@@ -978,7 +978,7 @@ static bool tokudb_sync_on_prepare(void) {
}
static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) {
- TOKUDB_DBUG_ENTER("");
+ TOKUDB_DBUG_ENTER("%u", all);
TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter");
int r = 0;
@@ -1006,6 +1006,22 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) {
r = txn->xa_prepare(txn, &thd_xid, syncflag);
// test hook to induce a crash on a debug build
DBUG_EXECUTE_IF("tokudb_crash_prepare_after", DBUG_SUICIDE(););
+
+ // XA log entries can be interleaved in the binlog since XA prepare on the master
+ // flushes to the binlog. There can be log entries from different clients pushed
+ // into the binlog before XA commit is executed on the master. Therefore, the slave
+ // thread must be able to juggle multiple XA transactions. Tokudb does this by
+ // zapping the client transaction context on the slave when executing the XA prepare
+ // and expecting to process XA commit with commit_by_xid (which supplies the XID so
+ // that the transaction can be looked up and committed).
+ if (r == 0 && all && thd->slave_thread) {
+ TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "zap txn context %u", thd_sql_command(thd));
+ if (thd_sql_command(thd) == SQLCOM_XA_PREPARE) {
+ trx->all = NULL;
+ trx->sub_sp_level = NULL;
+ trx->sp_level = NULL;
+ }
+ }
} else {
TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "nothing to prepare %d", all);
}
@@ -1036,6 +1052,7 @@ static int tokudb_xa_recover(handlerton* hton, XID* xid_list, uint len) {
static int tokudb_commit_by_xid(handlerton* hton, XID* xid) {
TOKUDB_DBUG_ENTER("");
TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter");
+ TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "xid %p", xid);
int r = 0;
DB_TXN* txn = NULL;
TOKU_XA_XID* toku_xid = (TOKU_XA_XID*)xid;
@@ -1055,6 +1072,7 @@ cleanup:
static int tokudb_rollback_by_xid(handlerton* hton, XID* xid) {
TOKUDB_DBUG_ENTER("");
TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter");
+ TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "xid %p", xid);
int r = 0;
DB_TXN* txn = NULL;
TOKU_XA_XID* toku_xid = (TOKU_XA_XID*)xid;