summaryrefslogtreecommitdiff
path: root/storage/tokudb/hatoku_hton.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/tokudb/hatoku_hton.cc')
-rw-r--r--storage/tokudb/hatoku_hton.cc60
1 files changed, 40 insertions, 20 deletions
diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc
index e17f94c2831..d282d68acc1 100644
--- a/storage/tokudb/hatoku_hton.cc
+++ b/storage/tokudb/hatoku_hton.cc
@@ -780,7 +780,7 @@ extern "C" enum durability_properties thd_get_durability_property(const MYSQL_TH
#endif
// Determine if an fsync is used when a transaction is committed.
-static bool tokudb_fsync_on_commit(THD *thd, tokudb_trx_data *trx, DB_TXN *txn) {
+static bool tokudb_sync_on_commit(THD *thd, tokudb_trx_data *trx, DB_TXN *txn) {
#if MYSQL_VERSION_ID >= 50600
// Check the client durability property which is set during 2PC
if (thd_get_durability_property(thd) == HA_IGNORE_DURABILITY)
@@ -791,17 +791,19 @@ static bool tokudb_fsync_on_commit(THD *thd, tokudb_trx_data *trx, DB_TXN *txn)
if (txn->is_prepared(txn) && mysql_bin_log.is_open())
return false;
#endif
+ if (tokudb_fsync_log_period > 0)
+ return false;
return THDVAR(thd, commit_sync) != 0;
}
static int tokudb_commit(handlerton * hton, THD * thd, bool all) {
- TOKUDB_DBUG_ENTER("");
+ TOKUDB_DBUG_ENTER("%u", all);
DBUG_PRINT("trans", ("ending transaction %s", all ? "all" : "stmt"));
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
DB_TXN **txn = all ? &trx->all : &trx->stmt;
DB_TXN *this_txn = *txn;
if (this_txn) {
- uint32_t syncflag = tokudb_fsync_on_commit(thd, trx, this_txn) ? 0 : DB_TXN_NOSYNC;
+ uint32_t syncflag = tokudb_sync_on_commit(thd, trx, this_txn) ? 0 : DB_TXN_NOSYNC;
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("commit trx %u txn %p syncflag %u", all, this_txn, syncflag);
}
@@ -811,11 +813,11 @@ static int tokudb_commit(handlerton * hton, THD * thd, bool all) {
commit_txn_with_progress(this_txn, syncflag, thd);
// test hook to induce a crash on a debug build
DBUG_EXECUTE_IF("tokudb_crash_commit_after", DBUG_SUICIDE(););
- if (this_txn == trx->sp_level) {
- trx->sp_level = 0;
- }
- *txn = 0;
+ *txn = NULL;
trx->sub_sp_level = NULL;
+ if (this_txn == trx->sp_level || trx->all == NULL) {
+ trx->sp_level = NULL;
+ }
}
else if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("nothing to commit %d", all);
@@ -825,7 +827,7 @@ static int tokudb_commit(handlerton * hton, THD * thd, bool all) {
}
static int tokudb_rollback(handlerton * hton, THD * thd, bool all) {
- TOKUDB_DBUG_ENTER("");
+ TOKUDB_DBUG_ENTER("%u", all);
DBUG_PRINT("trans", ("aborting transaction %s", all ? "all" : "stmt"));
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
DB_TXN **txn = all ? &trx->all : &trx->stmt;
@@ -836,11 +838,11 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) {
}
tokudb_cleanup_handlers(trx, this_txn);
abort_txn_with_progress(this_txn, thd);
- if (this_txn == trx->sp_level) {
- trx->sp_level = 0;
- }
- *txn = 0;
+ *txn = NULL;
trx->sub_sp_level = NULL;
+ if (this_txn == trx->sp_level || trx->all == NULL) {
+ trx->sp_level = NULL;
+ }
}
else {
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
@@ -852,6 +854,13 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) {
}
#if TOKU_INCLUDE_XA
+static bool tokudb_sync_on_prepare(void) {
+ // skip sync of log if fsync log period > 0
+ if (tokudb_fsync_log_period > 0)
+ return false;
+ else
+ return true;
+}
static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) {
TOKUDB_DBUG_ENTER("");
@@ -866,6 +875,7 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) {
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
DB_TXN* txn = all ? trx->all : trx->stmt;
if (txn) {
+ uint32_t syncflag = tokudb_sync_on_prepare() ? 0 : DB_TXN_NOSYNC;
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("doing txn prepare:%d:%p", all, txn);
}
@@ -874,7 +884,7 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) {
thd_get_xid(thd, (MYSQL_XID*) &thd_xid);
// test hook to induce a crash on a debug build
DBUG_EXECUTE_IF("tokudb_crash_prepare_before", DBUG_SUICIDE(););
- r = txn->xa_prepare(txn, &thd_xid);
+ 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(););
}
@@ -939,7 +949,7 @@ cleanup:
#endif
static int tokudb_savepoint(handlerton * hton, THD * thd, void *savepoint) {
- TOKUDB_DBUG_ENTER("");
+ TOKUDB_DBUG_ENTER("%p", savepoint);
int error;
SP_INFO save_info = (SP_INFO)savepoint;
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
@@ -960,6 +970,9 @@ static int tokudb_savepoint(handlerton * hton, THD * thd, void *savepoint) {
trx->sp_level = save_info->txn;
save_info->in_sub_stmt = false;
}
+ if (tokudb_debug & TOKUDB_DEBUG_TXN) {
+ TOKUDB_TRACE("begin txn %p", save_info->txn);
+ }
save_info->trx = trx;
error = 0;
cleanup:
@@ -967,7 +980,7 @@ cleanup:
}
static int tokudb_rollback_to_savepoint(handlerton * hton, THD * thd, void *savepoint) {
- TOKUDB_DBUG_ENTER("");
+ TOKUDB_DBUG_ENTER("%p", savepoint);
int error;
SP_INFO save_info = (SP_INFO)savepoint;
DB_TXN* parent = NULL;
@@ -975,6 +988,9 @@ static int tokudb_rollback_to_savepoint(handlerton * hton, THD * thd, void *save
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
parent = txn_to_rollback->parent;
+ if (tokudb_debug & TOKUDB_DEBUG_TXN) {
+ TOKUDB_TRACE("rollback txn %p", txn_to_rollback);
+ }
if (!(error = txn_to_rollback->abort(txn_to_rollback))) {
if (save_info->in_sub_stmt) {
trx->sub_sp_level = parent;
@@ -988,24 +1004,27 @@ static int tokudb_rollback_to_savepoint(handlerton * hton, THD * thd, void *save
}
static int tokudb_release_savepoint(handlerton * hton, THD * thd, void *savepoint) {
- TOKUDB_DBUG_ENTER("");
- int error;
-
+ TOKUDB_DBUG_ENTER("%p", savepoint);
+ int error = 0;
SP_INFO save_info = (SP_INFO)savepoint;
DB_TXN* parent = NULL;
DB_TXN* txn_to_commit = save_info->txn;
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
parent = txn_to_commit->parent;
- if (!(error = txn_to_commit->commit(txn_to_commit, 0))) {
+ if (tokudb_debug & TOKUDB_DEBUG_TXN) {
+ TOKUDB_TRACE("commit txn %p", txn_to_commit);
+ }
+ DB_TXN *child = txn_to_commit->get_child(txn_to_commit);
+ if (child == NULL && !(error = txn_to_commit->commit(txn_to_commit, 0))) {
if (save_info->in_sub_stmt) {
trx->sub_sp_level = parent;
}
else {
trx->sp_level = parent;
}
- save_info->txn = NULL;
}
+ save_info->txn = NULL;
TOKUDB_DBUG_RETURN(error);
}
@@ -1447,6 +1466,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(disable_slow_upsert),
#endif
MYSQL_SYSVAR(analyze_time),
+ MYSQL_SYSVAR(analyze_delete_fraction),
MYSQL_SYSVAR(fsync_log_period),
#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
MYSQL_SYSVAR(gdb_path),