diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/include/cursor.i')
-rw-r--r-- | src/third_party/wiredtiger/src/include/cursor.i | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/third_party/wiredtiger/src/include/cursor.i b/src/third_party/wiredtiger/src/include/cursor.i index 362efea63a9..99354198433 100644 --- a/src/third_party/wiredtiger/src/include/cursor.i +++ b/src/third_party/wiredtiger/src/include/cursor.i @@ -173,13 +173,9 @@ __cursor_enter(WT_SESSION_IMPL *session) static inline void __cursor_leave(WT_SESSION_IMPL *session) { - /* - * Decrement the count of active cursors in the session. When that goes to zero, there are no - * active cursors, and we can release any snapshot we're holding for read committed isolation. - */ + /* Decrement the count of active cursors in the session. */ WT_ASSERT(session, session->ncursors > 0); - if (--session->ncursors == 0) - __wt_txn_read_last(session); + --session->ncursors; } /* @@ -189,20 +185,32 @@ __cursor_leave(WT_SESSION_IMPL *session) static inline int __cursor_reset(WT_CURSOR_BTREE *cbt) { + WT_CURSOR *cursor; WT_DECL_RET; WT_SESSION_IMPL *session; + cursor = &cbt->iface; session = CUR2S(cbt); +#ifdef HAVE_DIAGNOSTIC + __wt_cursor_key_order_reset(cbt); /* Clear key-order checks. */ +#endif __cursor_pos_clear(cbt); /* If the cursor was active, deactivate it. */ if (F_ISSET(cbt, WT_CBT_ACTIVE)) { - if (!F_ISSET(cbt, WT_CBT_NO_TXN)) + if (!F_ISSET(cbt, WT_CBT_NO_TRACKING)) __cursor_leave(session); F_CLR(cbt, WT_CBT_ACTIVE); } + /* + * When the count of active cursors in the session goes to zero, there are no active cursors, + * and we can release any snapshot we're holding for read committed isolation. + */ + if (session->ncursors == 0 && !F_ISSET(cbt, WT_CBT_NO_TXN)) + __wt_txn_read_last(session); + /* If we're not holding a cursor reference, we're done. */ if (cbt->ref == NULL) return (0); @@ -223,12 +231,15 @@ __cursor_reset(WT_CURSOR_BTREE *cbt) cbt->page_deleted_count = 0; /* - * Release any page references we're holding. This can trigger eviction (e.g., forced eviction - * of big pages), so it's important to do after releasing our snapshot above. - * - * Clear the reference regardless, so we don't try the release twice. + * Release any page references we're holding. This can trigger eviction (for example, forced + * eviction of big pages), so it must happen after releasing our snapshot above. Additionally, + * there's a debug mode where an application can force the eviction in order to test or stress + * the system. Clear the reference so we never try the release twice. */ - ret = __wt_page_release(session, cbt->ref, 0); + if (F_ISSET(cursor, WT_CURSTD_DEBUG_RESET_EVICT)) + WT_TRET_BUSY_OK(__wt_page_release_evict(session, cbt->ref, 0)); + else + ret = __wt_page_release(session, cbt->ref, 0); cbt->ref = NULL; return (ret); @@ -377,12 +388,8 @@ __cursor_func_init(WT_CURSOR_BTREE *cbt, bool reenter) session = CUR2S(cbt); - if (reenter) { -#ifdef HAVE_DIAGNOSTIC - __wt_cursor_key_order_reset(cbt); -#endif + if (reenter) WT_RET(__cursor_reset(cbt)); - } /* * Any old insert position is now invalid. We rely on this being cleared to detect if a new @@ -395,7 +402,7 @@ __cursor_func_init(WT_CURSOR_BTREE *cbt, bool reenter) /* Activate the file cursor. */ if (!F_ISSET(cbt, WT_CBT_ACTIVE)) { - if (!F_ISSET(cbt, WT_CBT_NO_TXN)) + if (!F_ISSET(cbt, WT_CBT_NO_TRACKING)) WT_RET(__cursor_enter(session)); F_SET(cbt, WT_CBT_ACTIVE); } |