diff options
author | Luke Chen <luke.chen@mongodb.com> | 2018-12-17 15:19:04 +1100 |
---|---|---|
committer | Luke Chen <luke.chen@mongodb.com> | 2018-12-17 15:19:04 +1100 |
commit | 0a29c7a7c5737b0e6027cf4cb01828b1abd8f41c (patch) | |
tree | b81a77c211f7e41a58a9eeb5612c4e38a796e682 /src/third_party/wiredtiger/src/include/txn.i | |
parent | 53d8b294b81f70ec183f5d95be6440ecc5f8a728 (diff) | |
download | mongo-0a29c7a7c5737b0e6027cf4cb01828b1abd8f41c.tar.gz |
Import wiredtiger: d5793d4dd57bb763079e3f79821444e7e666ff44 from branch mongodb-4.2
ref: 5812c92f5f..d5793d4dd5
for: 4.1.7
WT-4280 Add debugging to know which session has a hazard pointer
WT-4430 Fix race between prepare and page instantiate with fast truncate
WT-4482 lint
Diffstat (limited to 'src/third_party/wiredtiger/src/include/txn.i')
-rw-r--r-- | src/third_party/wiredtiger/src/include/txn.i | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/src/third_party/wiredtiger/src/include/txn.i b/src/third_party/wiredtiger/src/include/txn.i index 7de59e498d4..a297db2cf9e 100644 --- a/src/third_party/wiredtiger/src/include/txn.i +++ b/src/third_party/wiredtiger/src/include/txn.i @@ -343,51 +343,56 @@ __wt_txn_unmodify(WT_SESSION_IMPL *session) } /* - * __wt_txn_op_commit_page_del -- - * Make the transaction ID and timestamp updates necessary to a ref that - * was created by a fast delete truncate operation. + * __wt_txn_op_apply_prepare_state -- + * Apply the correct prepare state and the timestamp to the ref and to any + * updates in the page del update list. */ static inline void -__wt_txn_op_commit_page_del(WT_SESSION_IMPL *session, WT_REF *ref) +__wt_txn_op_apply_prepare_state( + WT_SESSION_IMPL *session, WT_REF *ref, bool commit) { WT_TXN *txn; WT_UPDATE **updp; + wt_timestamp_t ts; uint32_t previous_state; + uint8_t prepare_state; txn = &session->txn; - /* Avoid locking the page if a previous eviction already cleaned up. */ - if (ref->page_del->update_list == NULL) - return; - /* - * Lock the ref to ensure we don't race with eviction freeing the - * page deleted update list. + * Lock the ref to ensure we don't race with eviction freeing the page + * deleted update list or with a page instantiate. */ for (;; __wt_yield()) { previous_state = ref->state; + WT_ASSERT(session, previous_state != WT_REF_READING); if (previous_state != WT_REF_LOCKED && __wt_atomic_casv32( &ref->state, previous_state, WT_REF_LOCKED)) break; } + if (commit) { + ts = txn->commit_timestamp; + prepare_state = WT_PREPARE_RESOLVED; + } else { + ts = txn->prepare_timestamp; + prepare_state = WT_PREPARE_INPROGRESS; + } for (updp = ref->page_del->update_list; updp != NULL && *updp != NULL; ++updp) { - (*updp)->timestamp = txn->commit_timestamp; - if (F_ISSET(txn, WT_TXN_PREPARE)) - /* - * Holding the ref locked means we have exclusive - * access, so don't need to use the prepare locked - * transition state. - */ - (*updp)->prepare_state = WT_PREPARE_RESOLVED; + (*updp)->timestamp = ts; + /* + * Holding the ref locked means we have exclusive access, so if + * we are committing we don't need to use the prepare locked + * transition state. + */ + (*updp)->prepare_state = prepare_state; } + ref->page_del->timestamp = ts; + WT_PUBLISH(ref->page_del->prepare_state, prepare_state); - /* - * Publish to ensure we don't let the page be evicted and the updates - * discarded before being written. - */ + /* Unlock the page by setting it back to it's previous state */ WT_REF_SET_STATE(ref, previous_state); } @@ -416,8 +421,13 @@ __wt_txn_op_set_timestamp(WT_SESSION_IMPL *session, WT_TXN_OP *op) return; if (F_ISSET(txn, WT_TXN_PREPARE)) { + /* + * We have a commit timestamp for a prepare transaction, this is + * only possible as part of a transaction commit call. + */ if (op->type == WT_TXN_OP_REF_DELETE) - __wt_txn_op_commit_page_del(session, op->u.ref); + __wt_txn_op_apply_prepare_state( + session, op->u.ref, true); else { upd = op->u.op_upd; |