diff options
Diffstat (limited to 'storage/tokudb/PerconaFT/ft/txn/txn.cc')
-rw-r--r-- | storage/tokudb/PerconaFT/ft/txn/txn.cc | 119 |
1 files changed, 61 insertions, 58 deletions
diff --git a/storage/tokudb/PerconaFT/ft/txn/txn.cc b/storage/tokudb/PerconaFT/ft/txn/txn.cc index a3ce6beb7b0..7327cbd9d24 100644 --- a/storage/tokudb/PerconaFT/ft/txn/txn.cc +++ b/storage/tokudb/PerconaFT/ft/txn/txn.cc @@ -45,8 +45,11 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #include "ft/txn/txn_manager.h" #include "util/status.h" -void -toku_txn_get_status(TXN_STATUS s) { +toku_instr_key *txn_lock_mutex_key; +toku_instr_key *txn_state_lock_mutex_key; +toku_instr_key *result_state_cond_key; + +void toku_txn_get_status(TXN_STATUS s) { txn_status.init(); *s = txn_status; } @@ -225,74 +228,74 @@ static void toku_txn_create_txn ( static txn_child_manager tcm; - struct tokutxn new_txn = { - .txnid = {.parent_id64 = TXNID_NONE, .child_id64 = TXNID_NONE }, - .snapshot_txnid64 = TXNID_NONE, - .snapshot_type = for_recovery ? TXN_SNAPSHOT_NONE : snapshot_type, - .for_recovery = for_recovery, - .logger = logger, - .parent = parent_tokutxn, - .child = NULL, - .child_manager_s = tcm, - .child_manager = NULL, - .container_db_txn = container_db_txn, - .live_root_txn_list = nullptr, - .xids = NULL, - .snapshot_next = NULL, - .snapshot_prev = NULL, - .begin_was_logged = false, - .declared_read_only = read_only, - .do_fsync = false, - .force_fsync_on_commit = false, - .do_fsync_lsn = ZERO_LSN, - .xa_xid = {0, 0, 0, ""}, - .progress_poll_fun = NULL, - .progress_poll_fun_extra = NULL, - - // You cannot initialize txn_lock a TOKU_MUTEX_INITIALIZER, because we - // will initialize it in the code below, and it cannot already - // be initialized at that point. Also, in general, you don't - // get to use PTHREAD_MUTEX_INITALIZER (which is what is inside - // TOKU_MUTEX_INITIALIZER) except in static variables, and this - // is initializing an auto variable. - // - // And we cannot simply avoid initializing these fields - // because, although it avoids -Wmissing-field-initializer - // errors under gcc, it gets other errors about non-trivial - // designated initializers not being supported. - - .txn_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER - .open_fts = open_fts, - .roll_info = roll_info, - .state_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER - .state_cond = ZERO_COND_INITIALIZER, // Not TOKU_COND_INITIALIZER - .state = TOKUTXN_LIVE, - .num_pin = 0, - .client_id = 0, - .client_extra = nullptr, - .start_time = time(NULL), - }; +struct tokutxn new_txn = { + .txnid = {.parent_id64 = TXNID_NONE, .child_id64 = TXNID_NONE }, + .snapshot_txnid64 = TXNID_NONE, + .snapshot_type = for_recovery ? TXN_SNAPSHOT_NONE : snapshot_type, + .for_recovery = for_recovery, + .logger = logger, + .parent = parent_tokutxn, + .child = NULL, + .child_manager_s = tcm, + .child_manager = NULL, + .container_db_txn = container_db_txn, + .live_root_txn_list = nullptr, + .xids = NULL, + .snapshot_next = NULL, + .snapshot_prev = NULL, + .begin_was_logged = false, + .declared_read_only = read_only, + .do_fsync = false, + .force_fsync_on_commit = false, + .do_fsync_lsn = ZERO_LSN, + .xa_xid = {0, 0, 0, ""}, + .progress_poll_fun = NULL, + .progress_poll_fun_extra = NULL, + + // You cannot initialize txn_lock a TOKU_MUTEX_INITIALIZER, because we + // will initialize it in the code below, and it cannot already + // be initialized at that point. Also, in general, you don't + // get to use PTHREAD_MUTEX_INITALIZER (which is what is inside + // TOKU_MUTEX_INITIALIZER) except in static variables, and this + // is initializing an auto variable. + // + // And we cannot simply avoid initializing these fields + // because, although it avoids -Wmissing-field-initializer + // errors under gcc, it gets other errors about non-trivial + // designated initializers not being supported. + + .txn_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER + .open_fts = open_fts, + .roll_info = roll_info, + .state_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER + .state_cond = ZERO_COND_INITIALIZER, // Not TOKU_COND_INITIALIZER + .state = TOKUTXN_LIVE, + .num_pin = 0, + .client_id = 0, + .client_extra = nullptr, + .start_time = time(NULL), +}; - TOKUTXN result = NULL; - XMEMDUP(result, &new_txn); - invalidate_xa_xid(&result->xa_xid); - if (parent_tokutxn == NULL) { - result->child_manager = &result->child_manager_s; - result->child_manager->init(result); +TOKUTXN result = NULL; +XMEMDUP(result, &new_txn); +invalidate_xa_xid(&result->xa_xid); +if (parent_tokutxn == NULL) { + result->child_manager = &result->child_manager_s; + result->child_manager->init(result); } else { result->child_manager = parent_tokutxn->child_manager; } - toku_mutex_init(&result->txn_lock, nullptr); + toku_mutex_init(*txn_lock_mutex_key, &result->txn_lock, nullptr); toku_pthread_mutexattr_t attr; toku_mutexattr_init(&attr); toku_mutexattr_settype(&attr, TOKU_MUTEX_ADAPTIVE); - toku_mutex_init(&result->state_lock, &attr); + toku_mutex_init(*txn_state_lock_mutex_key, &result->state_lock, &attr); toku_mutexattr_destroy(&attr); - toku_cond_init(&result->state_cond, nullptr); + toku_cond_init(*result_state_cond_key, &result->state_cond, nullptr); *tokutxn = result; |