diff --git a/newbrt/rollback.c b/newbrt/rollback.c index 9243c2ec0c8..7f9af8c713c 100644 --- a/newbrt/rollback.c +++ b/newbrt/rollback.c @@ -241,6 +241,13 @@ void toku_rollback_txn_close (TOKUTXN txn) { r = toku_omt_delete_at(txn->logger->live_root_txns, idx); assert(r==0); } + // + // if this txn created a snapshot, make necessary modifications to list of snapshot txnids and live_list_reverse + // the order of operations is important. We first remove the txnid from the list of snapshot txnids. This is + // necessary because root snapshot transactions are in their own live lists. If we do not remove + // the txnid from the snapshot txnid list first, then when we go to make the modifications to + // live_list_reverse, we have trouble. We end up never removing (id, id) from live_list_reverse + // if (txn->snapshot_type != TXN_SNAPSHOT_NONE && (txn->parent==NULL || txn->snapshot_type == TXN_SNAPSHOT_CHILD)) { { u_int32_t idx; diff --git a/newbrt/txn.c b/newbrt/txn.c index 4d65713db1d..1385a719948 100644 --- a/newbrt/txn.c +++ b/newbrt/txn.c @@ -196,6 +196,21 @@ int toku_txn_begin_with_xid ( r = toku_omt_insert_at(logger->live_txns, result, toku_omt_size(logger->live_txns)); if (r!=0) goto died; + // + // maintain the data structures necessary for MVCC: + // 1. add txn to list of live_root_txns if this is a root transaction + // 2. if the transaction is creating a snapshot: + // - create a live list for the transaction + // - add the id to the list of snapshot ids + // - make the necessary modifications to the live_list_reverse + // + // The order of operations is important here, and must be taken + // into account when the transaction is closed. The txn is added + // to the live_root_txns first (if it is a root txn). This has the implication + // that a root level snapshot transaction is in its own live list. This fact + // is taken into account when the transaction is closed. + // + // add ancestor information, and maintain global live root txn list if (parent_tokutxn==NULL) { //Add txn to list (omt) of live root txns