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 | |
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')
-rw-r--r-- | src/third_party/wiredtiger/src/include/extern.h | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/mutex.h | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/mutex.i | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/stat.h | 8 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/txn.i | 56 |
5 files changed, 41 insertions, 29 deletions
diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index d4a72bc340b..50eaa16e847 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -717,7 +717,7 @@ __wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, bool *busyp ); extern int __wt_hazard_clear(WT_SESSION_IMPL *session, WT_REF *ref) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_hazard_close(WT_SESSION_IMPL *session); -extern WT_HAZARD *__wt_hazard_check(WT_SESSION_IMPL *session, WT_REF *ref); +extern WT_HAZARD *__wt_hazard_check(WT_SESSION_IMPL *session, WT_REF *ref, WT_SESSION_IMPL **sessionp); extern u_int __wt_hazard_count(WT_SESSION_IMPL *session, WT_REF *ref); extern bool __wt_hazard_check_assert(WT_SESSION_IMPL *session, void *ref, bool waitfor) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_fill_hex(const uint8_t *src, size_t src_max, uint8_t *dest, size_t dest_max, size_t *lenp); diff --git a/src/third_party/wiredtiger/src/include/mutex.h b/src/third_party/wiredtiger/src/include/mutex.h index 5c836526a21..703ee12afc1 100644 --- a/src/third_party/wiredtiger/src/include/mutex.h +++ b/src/third_party/wiredtiger/src/include/mutex.h @@ -82,7 +82,7 @@ struct __wt_rwlock { /* Read/write lock */ WT_RWLOCK_INIT_TRACKED(session, l, name); \ (l)->stat_session_usecs_off = \ (int16_t)WT_SESSION_STATS_FIELD_TO_OFFSET( \ - &(session->stats), lock_##name##_wait); \ + &(session)->stats, lock_##name##_wait); \ } while (0) /* diff --git a/src/third_party/wiredtiger/src/include/mutex.i b/src/third_party/wiredtiger/src/include/mutex.i index d7f715e81e1..93c745bd5fc 100644 --- a/src/third_party/wiredtiger/src/include/mutex.i +++ b/src/third_party/wiredtiger/src/include/mutex.i @@ -290,7 +290,7 @@ __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) WT_SPIN_INIT_TRACKED(session, t, name); \ (t)->stat_session_usecs_off = \ (int16_t)WT_SESSION_STATS_FIELD_TO_OFFSET( \ - &(session->stats), lock_##name##_wait); \ + &(session)->stats, lock_##name##_wait); \ } while (0) /* diff --git a/src/third_party/wiredtiger/src/include/stat.h b/src/third_party/wiredtiger/src/include/stat.h index c54a9fcc8b0..35bd30419da 100644 --- a/src/third_party/wiredtiger/src/include/stat.h +++ b/src/third_party/wiredtiger/src/include/stat.h @@ -166,7 +166,8 @@ __wt_stats_clear(void *stats_arg, int slot) } while (0) #define WT_STAT_DECRV_ATOMIC_BASE(session, stat, fld, value) do { \ if (WT_STAT_ENABLED(session)) \ - __wt_atomic_subi64(&(stat)->fld, (int64_t)(value)); \ + (void) \ + __wt_atomic_subi64(&(stat)->fld, (int64_t)(value)); \ } while (0) #define WT_STAT_INCRV_BASE(session, stat, fld, value) do { \ if (WT_STAT_ENABLED(session)) \ @@ -174,7 +175,8 @@ __wt_stats_clear(void *stats_arg, int slot) } while (0) #define WT_STAT_INCRV_ATOMIC_BASE(session, stat, fld, value) do { \ if (WT_STAT_ENABLED(session)) \ - __wt_atomic_addi64(&(stat)->fld, (int64_t)(value)); \ + (void) \ + __wt_atomic_addi64(&(stat)->fld, (int64_t)(value)); \ } while (0) #define WT_STAT_DECRV(session, stats, fld, value) do { \ @@ -265,7 +267,7 @@ __wt_stats_clear(void *stats_arg, int slot) * Update per session statistics. */ #define WT_STAT_SESSION_INCRV(session, fld, value) \ - WT_STAT_INCRV_BASE(session, &session->stats, fld, value) + WT_STAT_INCRV_BASE(session, &(session)->stats, fld, value) /* * Construct histogram increment functions to put the passed value into the 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; |