Commit 8fd0bcee authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3258 changes found during code review refs[t:3258]

git-svn-id: file:///svn/toku/tokudb@28492 c7de825b-a66e-492c-adef-691d508d4ae1
parent fe75c775
......@@ -779,7 +779,7 @@ int toku_get_and_pin_rollback_log(TOKUTXN txn, TXNID xid, uint64_t sequence, BLO
}
int toku_get_and_pin_rollback_log_for_new_entry (TOKUTXN txn, ROLLBACK_LOG_NODE *result) {
assert(txn->state == TOKUTXN_LIVE);
invariant(txn->state == TOKUTXN_LIVE); // #3258
int r;
ROLLBACK_LOG_NODE log;
if (txn_has_inprogress_rollback_log(txn)) {
......
......@@ -354,7 +354,7 @@ local_checkpoints_and_log_xcommit(void *thunk) {
int toku_txn_commit_with_lsn(TOKUTXN txn, int nosync, YIELDF yield, void *yieldv, LSN oplsn,
TXN_PROGRESS_POLL_FUNCTION poll, void *poll_extra) {
txn->state = TOKUTXN_COMMIT;
txn->state = TOKUTXN_COMMITTING;
if (garbage_collection_debug) {
verify_snapshot_system(txn->logger);
}
......@@ -391,7 +391,7 @@ int toku_txn_abort_txn(TOKUTXN txn, YIELDF yield, void *yieldv,
int toku_txn_abort_with_lsn(TOKUTXN txn, YIELDF yield, void *yieldv, LSN oplsn,
TXN_PROGRESS_POLL_FUNCTION poll, void *poll_extra) {
txn->state = TOKUTXN_ABORT;
txn->state = TOKUTXN_ABORTING;
if (garbage_collection_debug) {
verify_snapshot_system(txn->logger);
}
......
......@@ -87,10 +87,10 @@ int toku_txn_ignore_remove(TOKUTXN txn, FILENUM filenum);
int toku_txn_ignore_contains(TOKUTXN txn, FILENUM filenum);
enum tokutxn_state {
TOKUTXN_NOT_LIVE,
TOKUTXN_LIVE,
TOKUTXN_COMMIT,
TOKUTXN_ABORT,
TOKUTXN_LIVE, // initial txn state
TOKUTXN_COMMITTING, // txn in the process of committing
TOKUTXN_ABORTING, // txn in the process of aborting
TOKUTXN_RETIRED, // txn no longer exists
};
typedef enum tokutxn_state TOKUTXN_STATE;
......
......@@ -185,9 +185,9 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule) {
XIDS xids = xids_get_root_xids();
TXNID outermost_xid = TXNID_NONE;
TOKUTXN_STATE outermost_xid_state = TOKUTXN_NOT_LIVE;
TOKUTXN_STATE outermost_xid_state = TOKUTXN_RETIRED;
// scan the provisional stack from bottom to top
// scan the provisional stack from the outermost to the innermost transaction record
uint32_t num_committed = ule_get_num_committed(ule);
uint32_t num_provisional = ule_get_num_provisional(ule);
for (uint64_t xrindex = num_committed; xrindex < num_committed + num_provisional; xrindex++) {
......@@ -198,10 +198,10 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule) {
TXNID this_xid = uxr_get_txnid(uxr);
TOKUTXN_STATE this_xid_state = indexer_xid_state(indexer, this_xid);
if (this_xid_state == TOKUTXN_ABORT)
if (this_xid_state == TOKUTXN_ABORTING)
break; // nothing to do once we reach a transaction that is aborting
if (xrindex == num_committed) {
if (xrindex == num_committed) { // if this is the outermost xr
outermost_xid = this_xid;
outermost_xid_state = this_xid_state;
result = indexer_set_xid(indexer, this_xid, &xids); // always add the outermost xid to the XIDS list
......@@ -211,7 +211,7 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule) {
break;
if (outermost_xid_state != TOKUTXN_LIVE && xrindex > num_committed)
invariant(this_xid_state == TOKUTXN_NOT_LIVE);
invariant(this_xid_state == TOKUTXN_RETIRED);
if (uxr_is_placeholder(uxr))
continue; // skip placeholders
......@@ -229,12 +229,12 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule) {
if (result == 0) {
// send the delete message
if (outermost_xid_state == TOKUTXN_LIVE) {
invariant(this_xid_state != TOKUTXN_ABORT);
invariant(this_xid_state != TOKUTXN_ABORTING);
result = indexer_brt_delete_provisional(indexer, hotdb, &indexer->i->hotkey, xids);
if (result == 0)
result = indexer_lock_key(indexer, hotdb, &indexer->i->hotkey, outermost_xid);
} else {
invariant(outermost_xid_state == TOKUTXN_NOT_LIVE || outermost_xid_state == TOKUTXN_COMMIT);
invariant(outermost_xid_state == TOKUTXN_RETIRED || outermost_xid_state == TOKUTXN_COMMITTING);
result = indexer_brt_delete_committed(indexer, hotdb, &indexer->i->hotkey, xids);
if (result == 0)
indexer_commit_keys_add(&indexer->i->commit_keys, indexer->i->hotkey.size, indexer->i->hotkey.data);
......@@ -255,15 +255,15 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule) {
if (result == 0) {
// send the insert message
if (outermost_xid_state == TOKUTXN_LIVE) {
invariant(this_xid_state != TOKUTXN_ABORT);
invariant(this_xid_state != TOKUTXN_ABORTING);
result = indexer_brt_insert_provisional(indexer, hotdb, &indexer->i->hotkey, &indexer->i->hotval, xids);
if (result == 0)
result = indexer_lock_key(indexer, hotdb, &indexer->i->hotkey, outermost_xid);
} else {
invariant(outermost_xid_state == TOKUTXN_NOT_LIVE || outermost_xid_state == TOKUTXN_COMMIT);
invariant(outermost_xid_state == TOKUTXN_RETIRED || outermost_xid_state == TOKUTXN_COMMITTING);
result = indexer_brt_insert_committed(indexer, hotdb, &indexer->i->hotkey, &indexer->i->hotval, xids);
#if 0
// no need to do this
// no need to do this because we do implicit commits on inserts
if (result == 0)
indexer_commit_keys_add(&indexer->i->commit_keys, indexer->i->hotkey.size, indexer->i->hotkey.data);
#endif
......@@ -355,11 +355,11 @@ indexer_generate_hot_key_val(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule, UXRH
return result;
}
// looks up the TOKUTXN by TXNID. if it does not exist then the transaction is committed.
// returns TRUE if the xid is committed. otherwise returns FALSE.
// return the state of a transaction given a transaction id. if the transaction no longer exists,
// then return TOKUTXN_RETIRED.
static TOKUTXN_STATE
indexer_xid_state(DB_INDEXER *indexer, TXNID xid) {
TOKUTXN_STATE result = TOKUTXN_NOT_LIVE;
TOKUTXN_STATE result = TOKUTXN_RETIRED;
// TEST
if (indexer->i->test_xid_state) {
result = indexer->i->test_xid_state(indexer, xid);
......
......@@ -17,8 +17,8 @@
#include "xids-internal.h"
typedef enum {
TOKUTXN_NOT_LIVE, TOKUTXN_LIVE, TOKUTXN_COMMIT, TOKUTXN_ABORT,
} TOKUTXN_STATE;
TOKUTXN_LIVE, TOKUTXN_COMMITTING, TOKUTXN_ABORTING, TOKUTXN_RETIRED,
} TOKUTXN_STATE; // see txn.h
struct txn {
TXNID xid;
......@@ -55,7 +55,7 @@ live_add(struct live *live, TXNID xid, TOKUTXN_STATE state) {
static int
txn_state(struct live *live, TXNID xid) {
int r = TOKUTXN_NOT_LIVE;
int r = TOKUTXN_RETIRED;
for (int i = 0; i < live->o; i++) {
if (live->txns[i].xid == xid) {
r = live->txns[i].state;
......@@ -340,13 +340,13 @@ read_test(char *testname, ULE ule) {
// xid <XID> [live|committing|aborting]
if (strcmp(fields[0], "xid") == 0 && nfields == 3) {
TXNID xid = atoll(fields[1]);
TOKUTXN_STATE state = TOKUTXN_NOT_LIVE;
TOKUTXN_STATE state = TOKUTXN_RETIRED;
if (strcmp(fields[2], "live") == 0)
state = TOKUTXN_LIVE;
else if (strcmp(fields[2], "committing") == 0)
state = TOKUTXN_COMMIT;
state = TOKUTXN_COMMITTING;
else if (strcmp(fields[2], "aborting") == 0)
state = TOKUTXN_ABORT;
state = TOKUTXN_ABORTING;
else
assert(0);
live_add(&live_xids, xid, state);
......
......@@ -31,8 +31,6 @@ uint64_t toku_test_get_latest_lsn(DB_ENV *env) __attribute__((__visibility__("de
// test-only function
extern int toku_test_get_checkpointing_user_data_status(void) __attribute__((__visibility__("default")));
void toku_test_set_yield_callback(void (*yield)(void *extra), void *extra) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
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