diff --git a/ft/txn.c b/ft/txn.c index 962763961e4..3feeb9d926a 100644 --- a/ft/txn.c +++ b/ft/txn.c @@ -519,9 +519,9 @@ toku_txn_is_read_only(TOKUTXN txn) { if (!txn->begin_was_logged) { // Did no work. invariant(txn->roll_info.num_rollentries == 0); - // Was not prepared. invariant(txn->do_fsync_lsn.lsn == ZERO_LSN.lsn); invariant(toku_omt_size(txn->open_fts) == 0); + invariant(txn->num_pin==0); return true; } return false; diff --git a/ft/txn_manager.c b/ft/txn_manager.c index ba7ae160b7b..c851b7455d0 100644 --- a/ft/txn_manager.c +++ b/ft/txn_manager.c @@ -773,10 +773,8 @@ static void invalidate_xa_xid (TOKU_XA_XID *xid) { } void toku_txn_manager_note_abort_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { - if (!txn->begin_was_logged) { - //Read only transaction + if (toku_txn_is_read_only(txn)) { invariant(txn->state==TOKUTXN_LIVE); - invariant(txn->num_pin==0); txn->state = TOKUTXN_ABORTING; goto done; } @@ -802,10 +800,8 @@ done: } void toku_txn_manager_note_commit_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { - if (!txn->begin_was_logged) { - //Read only transaction + if (toku_txn_is_read_only(txn)) { invariant(txn->state==TOKUTXN_LIVE); - invariant(txn->num_pin==0); txn->state = TOKUTXN_COMMITTING; goto done; } diff --git a/src/ydb-internal.h b/src/ydb-internal.h index 6a60e3d5c2c..dcbf2e2991a 100644 --- a/src/ydb-internal.h +++ b/src/ydb-internal.h @@ -68,7 +68,7 @@ struct __toku_db_env_internal { TOKULOGGER logger; toku_ltm* ltm; - int open_txns; // Number of open transactions + int32_t open_txns; // Number of open transactions DB *directory; // Maps dnames to inames DB *persistent_environment; // Stores environment settings, can be used for upgrade OMT open_dbs; // Stores open db handles, sorted first by dname and then by numerical value of pointer to the db (arbitrarily assigned memory location) diff --git a/src/ydb_txn.c b/src/ydb_txn.c index 120f8799f9c..65358a1834a 100644 --- a/src/ydb_txn.c +++ b/src/ydb_txn.c @@ -47,8 +47,8 @@ toku_txn_release_locks(DB_TXN* txn) { static void toku_txn_destroy(DB_TXN *txn) { - (void) __sync_fetch_and_sub(&txn->mgrp->i->open_txns, 1); - assert(txn->mgrp->i->open_txns>=0); + int32_t open_txns = __sync_sub_and_fetch(&txn->mgrp->i->open_txns, 1); + invariant(open-txns > 0); toku_txn_destroy_txn(db_txn_struct_i(txn)->tokutxn); toku_mutex_destroy(&db_txn_struct_i(txn)->txn_mutex); #if !TOKUDB_NATIVE_H