diff --git a/src/btree/bt_curnext.c b/src/btree/bt_curnext.c index 32a6172cd..8811aa1b3 100644 --- a/src/btree/bt_curnext.c +++ b/src/btree/bt_curnext.c @@ -676,7 +676,7 @@ __wt_btcur_next_prefix(WT_CURSOR_BTREE *cbt, WT_ITEM *prefix, bool truncating) WT_SESSION_IMPL *session; size_t pages_skipped_count, total_skipped, skipped; uint32_t flags; - bool newpage, restart; + bool newpage, restart, busy; cursor = &cbt->iface; session = CUR2S(cbt); @@ -792,6 +792,15 @@ __wt_btcur_next_prefix(WT_CURSOR_BTREE *cbt, WT_ITEM *prefix, bool truncating) skip_page: if (F_ISSET(cbt, WT_CBT_READ_ONCE)) LF_SET(WT_READ_WONT_NEED); + +#ifdef HAVE_DIAGNOSTIC + if (cbt->last_ref) + WT_ERR(__wt_page_release(session, cbt->last_ref, 0)); + cbt->last_ref = cbt->ref; + if (cbt->last_ref) + WT_ERR( + __wt_hazard_set_func(session, cbt->last_ref, &busy, __PRETTY_FUNCTION__, __LINE__)); +#endif WT_ERR(__wt_tree_walk(session, &cbt->ref, flags)); WT_ERR_TEST(cbt->ref == NULL, WT_NOTFOUND, false); } diff --git a/src/btree/bt_curprev.c b/src/btree/bt_curprev.c index bcf9f7e6d..0218a42d9 100644 --- a/src/btree/bt_curprev.c +++ b/src/btree/bt_curprev.c @@ -622,7 +622,7 @@ __wt_btcur_prev_prefix(WT_CURSOR_BTREE *cbt, WT_ITEM *prefix, bool truncating) WT_SESSION_IMPL *session; size_t pages_skipped_count, total_skipped, skipped; uint32_t flags; - bool newpage, restart; + bool newpage, restart, busy; cursor = &cbt->iface; session = CUR2S(cbt); @@ -740,6 +740,15 @@ __wt_btcur_prev_prefix(WT_CURSOR_BTREE *cbt, WT_ITEM *prefix, bool truncating) skip_page: if (F_ISSET(cbt, WT_CBT_READ_ONCE)) LF_SET(WT_READ_WONT_NEED); + +#ifdef HAVE_DIAGNOSTIC + if (cbt->last_ref) + WT_ERR(__wt_page_release(session, cbt->last_ref, 0)); + cbt->last_ref = cbt->ref; + if (cbt->last_ref) + WT_ERR( + __wt_hazard_set_func(session, cbt->last_ref, &busy, __PRETTY_FUNCTION__, __LINE__)); +#endif WT_ERR(__wt_tree_walk(session, &cbt->ref, flags)); WT_ERR_TEST(cbt->ref == NULL, WT_NOTFOUND, false); } diff --git a/src/btree/bt_debug.c b/src/btree/bt_debug.c index 81f419184..80a2fbbae 100644 --- a/src/btree/bt_debug.c +++ b/src/btree/bt_debug.c @@ -942,7 +942,15 @@ __wt_debug_cursor_page(void *cursor_arg, const char *ofile) cbt = cursor_arg; session = CUR2S(cursor_arg); + WT_RET(__wt_msg(session, "dumping the current cursor page")); WT_WITH_BTREE(session, CUR2BT(cbt), ret = __wt_debug_page(session, NULL, cbt->ref, ofile)); +#ifdef HAVE_DIAGNOSTIC + if (cbt->last_ref != NULL) { + WT_RET(__wt_msg(session, "dumping the previous cursor page")); + WT_WITH_BTREE( + session, CUR2BT(cbt), ret = __wt_debug_page(session, NULL, cbt->last_ref, ofile)); + } +#endif return (ret); } diff --git a/src/include/cursor.h b/src/include/cursor.h index 569da6aab..cf22340c8 100644 --- a/src/include/cursor.h +++ b/src/include/cursor.h @@ -93,8 +93,9 @@ struct __wt_cursor_btree { * stack (the stack of skiplist entries leading to the insert point). The search functions also * return the relationship of the search key to the found key. */ - WT_REF *ref; /* Current page */ - uint32_t slot; /* WT_COL/WT_ROW 0-based slot */ + WT_REF *last_ref; /* Previous page */ + WT_REF *ref; /* Current page */ + uint32_t slot; /* WT_COL/WT_ROW 0-based slot */ WT_INSERT_HEAD *ins_head; /* Insert chain head */ WT_INSERT *ins; /* Current insert node */ diff --git a/src/include/cursor_inline.h b/src/include/cursor_inline.h index 49179efd0..1e6888b57 100644 --- a/src/include/cursor_inline.h +++ b/src/include/cursor_inline.h @@ -237,6 +237,10 @@ __cursor_reset(WT_CURSOR_BTREE *cbt) if (session->ncursors == 0 && !F_ISSET(cbt, WT_CBT_NO_TXN)) __wt_txn_read_last(session); + /* + if (cbt->last_ref) + WT_RET(__wt_page_release(session, cbt->last_ref, 0)); + */ /* If we're not holding a cursor reference, we're done. */ if (cbt->ref == NULL) return (0);