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