summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/include/cursor.i
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2020-06-10 16:12:22 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-10 06:31:42 +0000
commitbea79f76addfe4b754c8696db029c5b3c762041c (patch)
tree187e6f29515fcdf6b14526a76071b98d27244ae0 /src/third_party/wiredtiger/src/include/cursor.i
parent2a20c87a57afdd20349ed35258b92f998a19603f (diff)
downloadmongo-bea79f76addfe4b754c8696db029c5b3c762041c.tar.gz
Import wiredtiger: 154719f3ff736872f67f2b3e9f4d8b396d2d8adf from branch mongodb-4.4r4.4.0-rc9
ref: bf1d78126c..154719f3ff for: 4.4.0-rc9 WT-6185 Insert full updates into the history store in some corner cases and add a history store c test WT-6257 Fix rows out-of-order in history store file WT-6339 Stop creating snapshots for history store cursors WT-6396 Fix wrong assert when inserting updates to the history store
Diffstat (limited to 'src/third_party/wiredtiger/src/include/cursor.i')
-rw-r--r--src/third_party/wiredtiger/src/include/cursor.i43
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);
}