Commit 7229b9f5 authored by Rich Prohaska's avatar Rich Prohaska

DB-785 turn off fsync on mariadb for 2PC transactions

parent de9a3786
...@@ -415,10 +415,10 @@ static int tokudb_init_func(void *p) { ...@@ -415,10 +415,10 @@ static int tokudb_init_func(void *p) {
tokudb_hton->commit = tokudb_commit; tokudb_hton->commit = tokudb_commit;
tokudb_hton->rollback = tokudb_rollback; tokudb_hton->rollback = tokudb_rollback;
#if TOKU_INCLUDE_XA #if TOKU_INCLUDE_XA
tokudb_hton->prepare=tokudb_xa_prepare; tokudb_hton->prepare = tokudb_xa_prepare;
tokudb_hton->recover=tokudb_xa_recover; tokudb_hton->recover = tokudb_xa_recover;
tokudb_hton->commit_by_xid=tokudb_commit_by_xid; tokudb_hton->commit_by_xid = tokudb_commit_by_xid;
tokudb_hton->rollback_by_xid=tokudb_rollback_by_xid; tokudb_hton->rollback_by_xid = tokudb_rollback_by_xid;
#endif #endif
tokudb_hton->panic = tokudb_end; tokudb_hton->panic = tokudb_end;
...@@ -776,13 +776,17 @@ static void tokudb_cleanup_handlers(tokudb_trx_data *trx, DB_TXN *txn) { ...@@ -776,13 +776,17 @@ static void tokudb_cleanup_handlers(tokudb_trx_data *trx, DB_TXN *txn) {
extern "C" enum durability_properties thd_get_durability_property(const MYSQL_THD thd); extern "C" enum durability_properties thd_get_durability_property(const MYSQL_THD thd);
#endif #endif
// Determine if an fsync is used when a transaction is committed. The MySQL durability property // Determine if an fsync is used when a transaction is committed.
// has precedence over the tokudb commit sync setting as it has a better idea of what is going on. static bool tokudb_fsync_on_commit(THD *thd, tokudb_trx_data *trx, DB_TXN *txn) {
static bool tokudb_fsync_on_commit(THD *thd) {
#if MYSQL_VERSION_ID >= 50600 #if MYSQL_VERSION_ID >= 50600
// Check the client durability property which is set during 2PC
if (thd_get_durability_property(thd) == HA_IGNORE_DURABILITY) if (thd_get_durability_property(thd) == HA_IGNORE_DURABILITY)
return false; return false;
else #endif
#if defined(MARIADB_BASE_VERSION)
// Check is the txn is prepared and the binlog is open
if (txn->is_prepared(txn) && mysql_bin_log.is_open())
return false;
#endif #endif
return THDVAR(thd, commit_sync) != 0; return THDVAR(thd, commit_sync) != 0;
} }
...@@ -790,11 +794,11 @@ static bool tokudb_fsync_on_commit(THD *thd) { ...@@ -790,11 +794,11 @@ static bool tokudb_fsync_on_commit(THD *thd) {
static int tokudb_commit(handlerton * hton, THD * thd, bool all) { static int tokudb_commit(handlerton * hton, THD * thd, bool all) {
TOKUDB_DBUG_ENTER(""); TOKUDB_DBUG_ENTER("");
DBUG_PRINT("trans", ("ending transaction %s", all ? "all" : "stmt")); DBUG_PRINT("trans", ("ending transaction %s", all ? "all" : "stmt"));
uint32_t syncflag = tokudb_fsync_on_commit(thd) ? 0 : DB_TXN_NOSYNC;
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton); tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
DB_TXN **txn = all ? &trx->all : &trx->stmt; DB_TXN **txn = all ? &trx->all : &trx->stmt;
DB_TXN *this_txn = *txn; DB_TXN *this_txn = *txn;
if (this_txn) { if (this_txn) {
uint32_t syncflag = tokudb_fsync_on_commit(thd, trx, this_txn) ? 0 : DB_TXN_NOSYNC;
if (tokudb_debug & TOKUDB_DEBUG_TXN) { if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("commit trx %u txn %p syncflag %u", all, this_txn, syncflag); TOKUDB_TRACE("commit trx %u txn %p syncflag %u", all, this_txn, syncflag);
} }
...@@ -850,7 +854,7 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { ...@@ -850,7 +854,7 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) {
TOKUDB_DBUG_ENTER(""); TOKUDB_DBUG_ENTER("");
int r = 0; int r = 0;
/* if support_xa is disable, just return */ // if tokudb_support_xa is disable, just return
if (!THDVAR(thd, support_xa)) { if (!THDVAR(thd, support_xa)) {
TOKUDB_DBUG_RETURN(r); TOKUDB_DBUG_RETURN(r);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment