summaryrefslogtreecommitdiff
path: root/storage/tokudb/hatoku_hton.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-05-11 13:12:18 +0200
committerSergei Golubchik <serg@mariadb.org>2018-05-11 13:15:10 +0200
commitc9717dc0190731c656cce31fa6e39a3db123e3af (patch)
tree3db056a3f50e565294d127edb5339afb0a994749 /storage/tokudb/hatoku_hton.cc
parent33721d91389759a917463a044fbd6f0b7654d629 (diff)
parent1d411a8a440922f0538c1be254d6f4396af453a1 (diff)
downloadmariadb-git-c9717dc0190731c656cce31fa6e39a3db123e3af.tar.gz
Merge branch '10.2' into 10.3
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 de8cc576c19..437c71f69dd 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;