summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Korteland <will.korteland@mongodb.com>2022-03-31 03:13:06 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-31 03:42:19 +0000
commit0bff6fd1ea45fa40010ef279a88ad2140543d7ea (patch)
treeed05041ae7977ea418f19c3a6d8b5b13563eccf8
parentd4ea852aec6939dbf9af34661918bb3c13d6d0fb (diff)
downloadmongo-0bff6fd1ea45fa40010ef279a88ad2140543d7ea.tar.gz
Import wiredtiger: b838e67911994b2f97abe8270a7cfd4d05a62adc from branch mongodb-master
ref: f1646b5376..b838e67911 for: 6.0.0 WT-8970 Check for positioned cursors before allowing RTS
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c58
2 files changed, 30 insertions, 30 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 0dde9171a99..fc8728340c7 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "f1646b537667ed61d1c43875e60f7188415b5d74"
+ "commit": "b838e67911994b2f97abe8270a7cfd4d05a62adc"
}
diff --git a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c
index 11333576dad..b4112f6f416 100644
--- a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c
+++ b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c
@@ -1340,23 +1340,27 @@ __rollback_to_stable_btree(WT_SESSION_IMPL *session, wt_timestamp_t rollback_tim
}
/*
- * __txn_user_active --
- * Return if there are any running user transactions.
+ * __rollback_to_stable_check --
+ * Check to the extent possible that the rollback request is reasonable.
*/
-static bool
-__txn_user_active(WT_SESSION_IMPL *session)
+static int
+__rollback_to_stable_check(WT_SESSION_IMPL *session)
{
WT_CONNECTION_IMPL *conn;
+ WT_DECL_RET;
WT_SESSION_IMPL *session_in_list;
uint32_t i, session_cnt;
- bool txn_active;
+ bool cursor_active, txn_active;
conn = S2C(session);
- txn_active = false;
+ cursor_active = txn_active = false;
WT_STAT_CONN_INCR(session, txn_walk_sessions);
/*
+ * Help the user comply with the requirement there be no concurrent user operations. It is okay
+ * to have a transaction in the prepared state.
+ *
* WT_TXN structures are allocated and freed as sessions are activated and closed. Lock the
* session open/close to ensure we don't race. This call is a rarely used RTS-only function,
* acquiring the lock shouldn't be an issue.
@@ -1375,35 +1379,27 @@ __txn_user_active(WT_SESSION_IMPL *session)
txn_active = true;
break;
}
+
+ /* Check if a user session has an active file cursor. */
+ if (session_in_list->ncursors != 0) {
+ cursor_active = true;
+ break;
+ }
}
__wt_spin_unlock(session, &conn->api_lock);
/*
- * A new transaction may start after we return from this call and callers should be aware of
- * this limitation.
- */
- return (txn_active);
-}
-
-/*
- * __rollback_to_stable_check --
- * Ensure the rollback request is reasonable.
- */
-static int
-__rollback_to_stable_check(WT_SESSION_IMPL *session)
-{
- WT_DECL_RET;
-
- /*
- * Help the user comply with the requirement that there are no concurrent user operations. It is
- * okay to have a transaction in prepared state.
+ * A new cursor may be positioned or a transaction may start after we return from this call and
+ * callers should be aware of this limitation.
*/
- if (__txn_user_active(session)) {
+ if (cursor_active)
+ WT_RET_MSG(session, EBUSY, "rollback_to_stable illegal with active file cursors");
+ if (txn_active) {
+ ret = EBUSY;
WT_TRET(__wt_verbose_dump_txn(session));
- WT_RET_MSG(session, EBUSY, "rollback_to_stable illegal with active transactions");
+ WT_RET_MSG(session, ret, "rollback_to_stable illegal with active transactions");
}
-
- return (ret);
+ return (0);
}
/*
@@ -1676,7 +1672,11 @@ __rollback_to_stable_btree_apply(
if (perform_rts || max_durable_ts > rollback_timestamp || prepared_updates ||
!durable_ts_found || has_txn_updates_gt_than_ckpt_snap) {
- ret = __wt_session_get_dhandle(session, uri, NULL, NULL, 0);
+ /*
+ * Open a handle; we're potentially opening a lot of handles and there's no reason to cache
+ * all of them for future unknown use, discard on close.
+ */
+ ret = __wt_session_get_dhandle(session, uri, NULL, NULL, WT_DHANDLE_DISCARD);
if (ret != 0)
WT_ERR_MSG(session, ret, "%s: unable to open handle%s", uri,
ret == EBUSY ? ", error indicates handle is unavailable due to concurrent use" : "");