Commit 3ac574c0 authored by Rich Prohaska's avatar Rich Prohaska

refs Tokutek/ft-engine#30 trace all txn begin calls

parent 0944d4b5
......@@ -91,16 +91,19 @@ PATENT RIGHTS GRANT:
#pragma implementation // gcc: Class implementation
#endif
#define MYSQL_SERVER 1
#include "hatoku_defines.h"
#include "hatoku_cmp.h"
extern "C" {
#include "stdint.h"
#define __STDC_FORMAT_MACROS
#include "inttypes.h"
#if defined(_WIN32)
#include "misc.h"
#endif
}
#define MYSQL_SERVER 1
#include "hatoku_defines.h"
#include "hatoku_cmp.h"
static inline void *thd_data_get(THD *thd, int slot) {
return thd->ha_data[slot].ha_ptr;
}
......@@ -1714,7 +1717,7 @@ int ha_tokudb::initialize_share(
}
else {
do_commit = true;
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) { goto exit; }
}
......@@ -1999,7 +2002,7 @@ int ha_tokudb::estimate_num_rows(DB* db, uint64_t* num_rows, DB_TXN* txn) {
DB_TXN* txn_to_use = NULL;
if (txn == NULL) {
error = db_env->txn_begin(db_env, 0, &txn_to_use, DB_READ_UNCOMMITTED);
error = txn_begin(db_env, 0, &txn_to_use, DB_READ_UNCOMMITTED);
if (error) goto cleanup;
do_commit = true;
}
......@@ -2047,7 +2050,7 @@ int ha_tokudb::remove_metadata(DB* db, void* key_data, uint key_size, DB_TXN* tr
// transaction to be used for putting metadata into status.tokudb
//
if (transaction == NULL) {
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) {
goto cleanup;
}
......@@ -2091,7 +2094,7 @@ int ha_tokudb::write_metadata(DB* db, void* key_data, uint key_size, void* val_d
// transaction to be used for putting metadata into status.tokudb
//
if (transaction == NULL) {
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) {
goto cleanup;
}
......@@ -3070,7 +3073,7 @@ void ha_tokudb::init_hidden_prim_key_info() {
}
else {
do_commit = true;
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
assert(error == 0);
}
......@@ -3287,7 +3290,7 @@ bool ha_tokudb::may_table_be_empty(DB_TXN *txn) {
DB_TXN* tmp_txn = NULL;
if (txn == NULL) {
error = db_env->txn_begin(db_env, 0, &tmp_txn, 0);
error = txn_begin(db_env, 0, &tmp_txn, 0);
if (error) {
goto cleanup;
}
......@@ -4071,7 +4074,7 @@ int ha_tokudb::write_row(uchar * record) {
create_sub_trans = (using_ignore && !(do_ignore_flag_optimization(thd,table,share->replace_into_fast)));
if (create_sub_trans) {
error = db_env->txn_begin(db_env, transaction, &sub_trans, DB_INHERIT_ISOLATION);
error = txn_begin(db_env, transaction, &sub_trans, DB_INHERIT_ISOLATION);
if (error) {
goto cleanup;
}
......@@ -4235,7 +4238,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
curr_num_DBs = share->num_DBs;
if (using_ignore) {
error = db_env->txn_begin(db_env, transaction, &sub_trans, DB_INHERIT_ISOLATION);
error = txn_begin(db_env, transaction, &sub_trans, DB_INHERIT_ISOLATION);
if (error) {
goto cleanup;
}
......@@ -5933,7 +5936,7 @@ int ha_tokudb::info(uint flag) {
TOKU_DB_FRAGMENTATION_S frag_info;
memset(&frag_info, 0, sizeof frag_info);
error = db_env->txn_begin(db_env, NULL, &txn, DB_READ_UNCOMMITTED);
error = txn_begin(db_env, NULL, &txn, DB_READ_UNCOMMITTED);
if (error) { goto cleanup; }
// we should always have a primary key
......@@ -6147,12 +6150,12 @@ int ha_tokudb::create_txn(THD* thd, tokudb_trx_data* trx) {
(thd_sql_command(thd) != SQLCOM_ALTER_TABLE)) {
/* QQQ We have to start a master transaction */
// DBUG_PRINT("trans", ("starting transaction all "));
if ((error = db_env->txn_begin(db_env, NULL, &trx->all, toku_iso_to_txn_flag(toku_iso_level)))) {
if ((error = txn_begin(db_env, NULL, &trx->all, toku_iso_to_txn_flag(toku_iso_level)))) {
trx->tokudb_lock_count--; // We didn't get the lock
goto cleanup;
}
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("just created master:%p\n", trx->all);
TOKUDB_TRACE("just created master %p\n", trx->all);
}
trx->sp_level = trx->all;
trans_register_ha(thd, true, tokudb_hton);
......@@ -6183,14 +6186,14 @@ int ha_tokudb::create_txn(THD* thd, tokudb_trx_data* trx) {
else {
txn_begin_flags = DB_INHERIT_ISOLATION;
}
if ((error = db_env->txn_begin(db_env, trx->sp_level, &trx->stmt, txn_begin_flags))) {
if ((error = txn_begin(db_env, trx->sp_level, &trx->stmt, txn_begin_flags))) {
/* We leave the possible master transaction open */
trx->tokudb_lock_count--; // We didn't get the lock
goto cleanup;
}
trx->sub_sp_level = trx->stmt;
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("just created stmt:%p:%p\n", trx->sp_level, trx->stmt);
TOKUDB_TRACE("just created stmt %p %p\n", trx->sp_level, trx->stmt);
}
reset_stmt_progress(&trx->stmt_progress);
trans_register_ha(thd, false, tokudb_hton);
......@@ -6990,7 +6993,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
}
else {
do_commit = true;
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) { goto cleanup; }
}
......@@ -7176,7 +7179,7 @@ int ha_tokudb::delete_or_rename_table (const char* from_name, const char* to_nam
memset(&curr_val, 0, sizeof(curr_val));
pthread_mutex_lock(&tokudb_meta_mutex);
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) { goto cleanup; }
//
......@@ -7521,7 +7524,7 @@ void ha_tokudb::init_auto_increment() {
value.flags = DB_DBT_USERMEM;
DB_TXN* txn = NULL;
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) {
share->last_auto_increment = 0;
}
......@@ -8252,7 +8255,7 @@ int ha_tokudb::delete_all_rows_internal() {
uint curr_num_DBs = 0;
DB_TXN* txn = NULL;
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) { goto cleanup; }
curr_num_DBs = table->s->keys + test(hidden_primary_key);
......
......@@ -329,9 +329,17 @@ static inline void make_name(char *newname, const char *tablename, const char *d
nn += sprintf(nn, "-%s", dictname);
}
static inline int txn_begin(DB_ENV *env, DB_TXN *parent, DB_TXN **txn, uint32_t flags) {
int r = env->txn_begin(env, parent, txn, flags);
if ((tokudb_debug & TOKUDB_DEBUG_TXN) && r == 0) {
TOKUDB_TRACE("begin txn %p %p %u\n", parent, *txn, flags);
}
return r;
}
static inline void commit_txn(DB_TXN* txn, uint32_t flags) {
if (tokudb_debug & TOKUDB_DEBUG_TXN)
TOKUDB_TRACE("commit_txn %p\n", txn);
TOKUDB_TRACE("commit txn %p\n", txn);
int r = txn->commit(txn, flags);
if (r != 0) {
sql_print_error("tried committing transaction %p and got error code %d", txn, r);
......@@ -341,7 +349,7 @@ static inline void commit_txn(DB_TXN* txn, uint32_t flags) {
static inline void abort_txn(DB_TXN* txn) {
if (tokudb_debug & TOKUDB_DEBUG_TXN)
TOKUDB_TRACE("abort_txn %p\n", txn);
TOKUDB_TRACE("abort txn %p\n", txn);
int r = txn->abort(txn);
if (r != 0) {
sql_print_error("tried aborting transaction %p and got error code %d", txn, r);
......
......@@ -932,16 +932,17 @@ static int tokudb_commit(handlerton * hton, THD * thd, bool all) {
uint32_t syncflag = THDVAR(thd, commit_sync) ? 0 : DB_TXN_NOSYNC;
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, hton->slot);
DB_TXN **txn = all ? &trx->all : &trx->stmt;
if (*txn) {
DB_TXN *this_txn = *txn;
if (this_txn) {
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("doing txn commit:%d:%p\n", all, *txn);
TOKUDB_TRACE("commit %d %p\n", all, this_txn);
}
// test hook to induce a crash on a debug build
DBUG_EXECUTE_IF("tokudb_crash_commit_before", DBUG_SUICIDE(););
commit_txn_with_progress(*txn, syncflag, thd);
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 (*txn == trx->sp_level) {
if (this_txn == trx->sp_level) {
trx->sp_level = 0;
}
*txn = 0;
......@@ -959,11 +960,12 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) {
DBUG_PRINT("trans", ("aborting transaction %s", all ? "all" : "stmt"));
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, hton->slot);
DB_TXN **txn = all ? &trx->all : &trx->stmt;
if (*txn) {
DB_TXN *this_txn = *txn;
if (this_txn) {
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("rollback:%p\n", *txn);
TOKUDB_TRACE("rollback %d %p\n", all, this_txn);
}
abort_txn_with_progress(*txn, thd);
abort_txn_with_progress(this_txn, thd);
if (*txn == trx->sp_level) {
trx->sp_level = 0;
}
......@@ -1067,7 +1069,7 @@ static int tokudb_savepoint(handlerton * hton, THD * thd, void *savepoint) {
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, hton->slot);
if (thd->in_sub_stmt) {
assert(trx->stmt);
error = db_env->txn_begin(db_env, trx->sub_sp_level, &(save_info->txn), DB_INHERIT_ISOLATION);
error = txn_begin(db_env, trx->sub_sp_level, &(save_info->txn), DB_INHERIT_ISOLATION);
if (error) {
goto cleanup;
}
......@@ -1075,7 +1077,7 @@ static int tokudb_savepoint(handlerton * hton, THD * thd, void *savepoint) {
save_info->in_sub_stmt = true;
}
else {
error = db_env->txn_begin(db_env, trx->sp_level, &(save_info->txn), DB_INHERIT_ISOLATION);
error = txn_begin(db_env, trx->sp_level, &(save_info->txn), DB_INHERIT_ISOLATION);
if (error) {
goto cleanup;
}
......@@ -1147,7 +1149,7 @@ static int tokudb_discover2(handlerton *hton, THD* thd, const char *db, const ch
memset(&key, 0, sizeof(key));
memset(&value, 0, sizeof(&value));
error = db_env->txn_begin(db_env, 0, &txn, 0);
error = txn_begin(db_env, 0, &txn, 0);
if (error) { goto cleanup; }
build_table_filename(path, sizeof(path) - 1, db, name, "", translate_name ? 0 : FN_IS_TMP);
......@@ -1215,7 +1217,7 @@ static int tokudb_dictionary_info(TABLE *table, THD *thd) {
DBT curr_val;
memset(&curr_key, 0, sizeof curr_key);
memset(&curr_val, 0, sizeof curr_val);
error = db_env->txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
if (error) {
goto cleanup;
}
......@@ -1332,7 +1334,7 @@ static int tokudb_fractal_tree_info(TABLE *table, THD *thd) {
DBT curr_val;
memset(&curr_key, 0, sizeof curr_key);
memset(&curr_val, 0, sizeof curr_val);
error = db_env->txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
if (error) {
goto cleanup;
}
......@@ -1496,7 +1498,7 @@ static int tokudb_fractal_tree_block_map(TABLE *table, THD *thd) {
DBT curr_val;
memset(&curr_key, 0, sizeof curr_key);
memset(&curr_val, 0, sizeof curr_val);
error = db_env->txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
if (error) {
goto cleanup;
}
......@@ -1542,7 +1544,7 @@ static int tokudb_get_user_data_size(TABLE *table, THD *thd, bool exact) {
memset(&curr_val, 0, sizeof curr_val);
pthread_mutex_lock(&tokudb_meta_mutex);
error = db_env->txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED);
if (error) {
goto cleanup;
}
......@@ -1559,7 +1561,7 @@ static int tokudb_get_user_data_size(TABLE *table, THD *thd, bool exact) {
if (thd->killed) {
break;
}
error = db_env->txn_begin(db_env, 0, &tmp_txn, DB_READ_UNCOMMITTED);
error = txn_begin(db_env, 0, &tmp_txn, DB_READ_UNCOMMITTED);
if (error) {
goto cleanup;
}
......
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