summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-12-21 17:29:16 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-21 07:28:22 +0000
commitfa4e83810374394841ddaf0bac9dcba87bf42207 (patch)
treed23e104c2ac1986d4b6cb3d2f53a67dc880a587b
parent293a1e802a8e1e9cf185f72c3a11ad0f63d6412e (diff)
downloadmongo-fa4e83810374394841ddaf0bac9dcba87bf42207.tar.gz
Import wiredtiger: fa57e011521883f1977ab6008b30a3bbd41cdd0d from branch mongodb-5.2
ref: 8cea6f7091..fa57e01152 for: 5.2.0-rc2 Reverted ticket(s): WT-8306 Resolve weak hazard pointer references on transaction commit and rollback
-rw-r--r--src/third_party/wiredtiger/dist/stat_data.py2
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/btree/col_modify.c12
-rw-r--r--src/third_party/wiredtiger/src/btree/row_modify.c12
-rw-r--r--src/third_party/wiredtiger/src/include/extern.h6
-rw-r--r--src/third_party/wiredtiger/src/include/stat.h2
-rw-r--r--src/third_party/wiredtiger/src/include/txn.h3
-rw-r--r--src/third_party/wiredtiger/src/include/txn_inline.h3
-rw-r--r--src/third_party/wiredtiger/src/include/wiredtiger.in14
-rw-r--r--src/third_party/wiredtiger/src/support/hazard_weak.c89
-rw-r--r--src/third_party/wiredtiger/src/support/stat.c6
-rw-r--r--src/third_party/wiredtiger/src/txn/txn.c177
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_log.c33
13 files changed, 59 insertions, 302 deletions
diff --git a/src/third_party/wiredtiger/dist/stat_data.py b/src/third_party/wiredtiger/dist/stat_data.py
index 91a5420fd78..abe9893c586 100644
--- a/src/third_party/wiredtiger/dist/stat_data.py
+++ b/src/third_party/wiredtiger/dist/stat_data.py
@@ -580,7 +580,6 @@ conn_stats = [
TxnStat('txn_checkpoint_time_recent', 'transaction checkpoint most recent time (msecs)', 'no_clear,no_scale'),
TxnStat('txn_checkpoint_time_total', 'transaction checkpoint total time (msecs)', 'no_clear,no_scale'),
TxnStat('txn_commit', 'transactions committed'),
- TxnStat('txn_commit_slow_resolved', 'transactions committed with one or more updates resolved through the slow path'),
TxnStat('txn_fail_cache', 'transaction failures due to history store'),
TxnStat('txn_pinned_checkpoint_range', 'transaction range of IDs currently pinned by a checkpoint', 'no_clear,no_scale'),
TxnStat('txn_pinned_range', 'transaction range of IDs currently pinned', 'no_clear,no_scale'),
@@ -600,7 +599,6 @@ conn_stats = [
TxnStat('txn_prepared_updates_rolledback', 'Number of prepared updates rolled back'),
TxnStat('txn_query_ts', 'query timestamp calls'),
TxnStat('txn_rollback', 'transactions rolled back'),
- TxnStat('txn_rollback_slow_resolved', 'transactions rolled back with one or more updates resolved through the slow path'),
TxnStat('txn_rollback_to_stable_running', 'transaction rollback to stable currently running', 'no_clear,no_scale'),
TxnStat('txn_rts', 'rollback to stable calls'),
TxnStat('txn_rts_pages_visited', 'rollback to stable pages visited'),
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 651f73f80e6..cd85356c542 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-5.2",
- "commit": "8cea6f709115ebfa38f66a8d720e9891db34da81"
+ "commit": "fa57e011521883f1977ab6008b30a3bbd41cdd0d"
}
diff --git a/src/third_party/wiredtiger/src/btree/col_modify.c b/src/third_party/wiredtiger/src/btree/col_modify.c
index 5c063fcb38a..db3fd5f8ab3 100644
--- a/src/third_party/wiredtiger/src/btree/col_modify.c
+++ b/src/third_party/wiredtiger/src/btree/col_modify.c
@@ -30,7 +30,6 @@ __wt_col_modify(WT_CURSOR_BTREE *cbt, uint64_t recno, const WT_ITEM *value, WT_U
WT_PAGE *page;
WT_PAGE_MODIFY *mod;
WT_SESSION_IMPL *session;
- WT_TXN *txn;
WT_UPDATE *last_upd, *old_upd, *upd;
wt_timestamp_t prev_upd_ts;
size_t ins_size, upd_size;
@@ -41,7 +40,6 @@ __wt_col_modify(WT_CURSOR_BTREE *cbt, uint64_t recno, const WT_ITEM *value, WT_U
ins = NULL;
page = cbt->ref->page;
session = CUR2S(cbt);
- txn = session->txn;
last_upd = NULL;
upd = upd_arg;
prev_upd_ts = WT_TS_NONE;
@@ -274,16 +272,6 @@ __wt_col_modify(WT_CURSOR_BTREE *cbt, uint64_t recno, const WT_ITEM *value, WT_U
__wt_txn_op_set_recno(session, cbt->recno);
}
- /*
- * This is temporary till we support more cases for resolving uncommitted updates: If we see a
- * reserve update, we don't want to continue with resolving uncommitted updates. We also have to
- * clear the weak hazard pointers we have already saved.
- */
- if (txn->resolve_weak_hazard_updates && modify_type == WT_UPDATE_RESERVE) {
- txn->resolve_weak_hazard_updates = false;
- WT_ERR(__wt_txn_op_list_clear_weak_hazard(session));
- }
-
if (0) {
err:
/* Remove the update from the current transaction; don't try to modify it on rollback. */
diff --git a/src/third_party/wiredtiger/src/btree/row_modify.c b/src/third_party/wiredtiger/src/btree/row_modify.c
index ca48d69b65c..779f5112c12 100644
--- a/src/third_party/wiredtiger/src/btree/row_modify.c
+++ b/src/third_party/wiredtiger/src/btree/row_modify.c
@@ -55,7 +55,6 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
WT_PAGE *page;
WT_PAGE_MODIFY *mod;
WT_SESSION_IMPL *session;
- WT_TXN *txn;
WT_UPDATE *last_upd, *old_upd, *upd, **upd_entry;
wt_timestamp_t prev_upd_ts;
size_t ins_size, upd_size;
@@ -66,7 +65,6 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
ins = NULL;
page = cbt->ref->page;
session = CUR2S(cbt);
- txn = session->txn;
last_upd = NULL;
upd = upd_arg;
prev_upd_ts = WT_TS_NONE;
@@ -264,16 +262,6 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
WT_ERR(__wt_txn_op_set_key(session, key));
}
- /*
- * This is temporary till we support more cases for resolving uncommitted updates: If we see a
- * reserve update, we don't want to continue with resolving uncommitted updates. We also have to
- * clear the weak hazard pointers we have already saved.
- */
- if (txn->resolve_weak_hazard_updates && modify_type == WT_UPDATE_RESERVE) {
- txn->resolve_weak_hazard_updates = false;
- WT_ERR(__wt_txn_op_list_clear_weak_hazard(session));
- }
-
if (0) {
err:
/* Remove the update from the current transaction, don't try to modify it on rollback. */
diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h
index 341ad47c941..9f750ed7092 100644
--- a/src/third_party/wiredtiger/src/include/extern.h
+++ b/src/third_party/wiredtiger/src/include/extern.h
@@ -777,12 +777,10 @@ extern int __wt_hazard_set_func(WT_SESSION_IMPL *session, WT_REF *ref, bool *bus
const char *func, int line
#endif
) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
-extern int __wt_hazard_weak_clear(WT_SESSION_IMPL *session, WT_HAZARD_WEAK **whpp)
+extern int __wt_hazard_weak_clear(WT_SESSION_IMPL *session, WT_TXN_OP *op)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_hazard_weak_set(WT_SESSION_IMPL *session, WT_REF *ref, WT_TXN_OP *op)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
-extern int __wt_hazard_weak_upgrade(WT_SESSION_IMPL *session, WT_HAZARD_WEAK **whpp, WT_REF **refp)
- WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_hex2byte(const u_char *from, u_char *to)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_hex_to_raw(WT_SESSION_IMPL *session, const char *from, WT_ITEM *to)
@@ -1579,8 +1577,6 @@ extern int __wt_txn_log_commit(WT_SESSION_IMPL *session, const char *cfg[])
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
-extern int __wt_txn_op_list_clear_weak_hazard(WT_SESSION_IMPL *session)
- WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_txn_op_printlog(WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end,
WT_TXN_PRINTLOG_ARGS *args) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_txn_parse_timestamp(WT_SESSION_IMPL *session, const char *name,
diff --git a/src/third_party/wiredtiger/src/include/stat.h b/src/third_party/wiredtiger/src/include/stat.h
index 8bd1ff2a0e4..069cef7806f 100644
--- a/src/third_party/wiredtiger/src/include/stat.h
+++ b/src/third_party/wiredtiger/src/include/stat.h
@@ -848,9 +848,7 @@ struct __wt_connection_stats {
int64_t txn_rollback_to_stable_running;
int64_t txn_walk_sessions;
int64_t txn_commit;
- int64_t txn_commit_slow_resolved;
int64_t txn_rollback;
- int64_t txn_rollback_slow_resolved;
int64_t txn_update_conflict;
};
diff --git a/src/third_party/wiredtiger/src/include/txn.h b/src/third_party/wiredtiger/src/include/txn.h
index 146cfab767b..b1c2b50a743 100644
--- a/src/third_party/wiredtiger/src/include/txn.h
+++ b/src/third_party/wiredtiger/src/include/txn.h
@@ -289,9 +289,6 @@ struct __wt_txn {
u_int prepare_count;
#endif
- /* This is a temporary feature flag to simplify resolving uncommitted updates. */
- bool resolve_weak_hazard_updates;
-
/* Scratch buffer for in-memory log records. */
WT_ITEM *logrec;
diff --git a/src/third_party/wiredtiger/src/include/txn_inline.h b/src/third_party/wiredtiger/src/include/txn_inline.h
index 3645c3092bb..96717ab4f92 100644
--- a/src/third_party/wiredtiger/src/include/txn_inline.h
+++ b/src/third_party/wiredtiger/src/include/txn_inline.h
@@ -1134,9 +1134,6 @@ __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[])
__wt_txn_get_snapshot(session);
}
- /* Disable the feature to resolve uncommitted updates during commit/rollback. */
- txn->resolve_weak_hazard_updates = false;
-
F_SET(txn, WT_TXN_RUNNING);
if (F_ISSET(S2C(session), WT_CONN_READONLY))
F_SET(txn, WT_TXN_READONLY);
diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in
index ac031ba0dc9..6685f47da7d 100644
--- a/src/third_party/wiredtiger/src/include/wiredtiger.in
+++ b/src/third_party/wiredtiger/src/include/wiredtiger.in
@@ -6354,20 +6354,10 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection);
#define WT_STAT_CONN_TXN_WALK_SESSIONS 1514
/*! transaction: transactions committed */
#define WT_STAT_CONN_TXN_COMMIT 1515
-/*!
- * transaction: transactions committed with one or more updates resolved
- * through the slow path
- */
-#define WT_STAT_CONN_TXN_COMMIT_SLOW_RESOLVED 1516
/*! transaction: transactions rolled back */
-#define WT_STAT_CONN_TXN_ROLLBACK 1517
-/*!
- * transaction: transactions rolled back with one or more updates
- * resolved through the slow path
- */
-#define WT_STAT_CONN_TXN_ROLLBACK_SLOW_RESOLVED 1518
+#define WT_STAT_CONN_TXN_ROLLBACK 1516
/*! transaction: update conflicts */
-#define WT_STAT_CONN_TXN_UPDATE_CONFLICT 1519
+#define WT_STAT_CONN_TXN_UPDATE_CONFLICT 1517
/*!
* @}
diff --git a/src/third_party/wiredtiger/src/support/hazard_weak.c b/src/third_party/wiredtiger/src/support/hazard_weak.c
index f1bc81ab0f0..463a8afe097 100644
--- a/src/third_party/wiredtiger/src/support/hazard_weak.c
+++ b/src/third_party/wiredtiger/src/support/hazard_weak.c
@@ -179,16 +179,27 @@ __wt_hazard_weak_set(WT_SESSION_IMPL *session, WT_REF *ref, WT_TXN_OP *op)
/*
* __wt_hazard_weak_clear --
- * Clear a weak hazard pointer.
+ * Clear a weak hazard pointer, given a modify operation.
*/
int
-__wt_hazard_weak_clear(WT_SESSION_IMPL *session, WT_HAZARD_WEAK **whpp)
+__wt_hazard_weak_clear(WT_SESSION_IMPL *session, WT_TXN_OP *op)
{
WT_HAZARD_WEAK *whp;
WT_HAZARD_WEAK_ARRAY *wha;
- whp = *whpp;
- *whpp = NULL;
+ /* If a file can never be evicted, hazard pointers aren't required. */
+ if (F_ISSET(op->btree, WT_BTREE_IN_MEMORY))
+ return (0);
+
+ whp = op->whp;
+ /*
+ * An empty slot reflects a serious error, we should always find the weak hazard pointer. Panic,
+ * because we messed up in and it could imply corruption.
+ */
+ if (whp == NULL || whp->ref == NULL)
+ WT_RET_PANIC(session, WT_PANIC,
+ "session %p: could not find the weak hazard pointer for a modify operation",
+ (void *)session);
/*
* We don't publish the weak hazard pointer clear as we only clear while holding the hazard
@@ -220,6 +231,9 @@ __wt_hazard_weak_clear(WT_SESSION_IMPL *session, WT_HAZARD_WEAK **whpp)
"session %p: While clearing weak hazard pointer could not find the array.",
(void *)session);
+ /* Clear the hazard stored in the modify operation. */
+ op->whp = NULL;
+
return (0);
}
@@ -264,70 +278,3 @@ __wt_hazard_weak_invalidate(WT_SESSION_IMPL *session, WT_REF *ref)
}
WT_STAT_CONN_INCRV(session, cache_hazard_walks, walk_cnt);
}
-
-/*
- * __wt_hazard_weak_upgrade --
- * Attempts to convert a weak hazard pointer into a full hazard pointer, failing if it has been
- * invalidated.
- */
-int
-__wt_hazard_weak_upgrade(WT_SESSION_IMPL *session, WT_HAZARD_WEAK **whpp, WT_REF **refp)
-{
- WT_DECL_RET;
- WT_HAZARD_WEAK *whp;
- bool busy;
-
- *refp = NULL;
- whp = *whpp;
-
- /* If a file can never be evicted, hazard pointers aren't required. */
- if (F_ISSET(S2BT(session), WT_BTREE_IN_MEMORY))
- return (0);
-
- /*
- * An empty slot reflects a serious error, we should always find the weak hazard pointer.
- * Assert, because we messed up in and it could imply corruption.
- */
- WT_ASSERT(session, whp != NULL && whp->ref != NULL);
-
- /* If the weak pointer has already been invalidated, we can't upgrade, we are done. */
- if (!whp->valid)
- WT_ERR(EBUSY);
-
-#ifdef HAVE_DIAGNOSTIC
- /*
- * Failing to upgrade the hazard pointer will encourage testing the resolution of uncommitted
- * updates more often.
- */
- if (__wt_random(&session->rnd) % 10 == 0)
- WT_ERR(EBUSY);
-#endif
-
- /*
- * Attempt to take a strong hazard pointer. Eviction on this page might prevent us from being
- * able to do so, in such a case we can't upgrade, we are done.
- */
- WT_ERR(__wt_hazard_set(session, whp->ref, &busy));
- if (busy)
- WT_ERR(EBUSY);
-
- /*
- * Paranoia: Eviction could still race with us and mark the pointers invalid after we have
- * checked their validity and before setting strong hazard pointer. Check again.
- */
- if (!whp->valid) {
- WT_ERR(__wt_hazard_clear(session, whp->ref));
- WT_ERR(EBUSY);
- }
-
- /*
- * We have successfully upgraded. Clear the weak hazards and return the page reference. We want
- * to clear the weak hazard pointers even in case of errors as we will take a slow path to
- * resolve the updates.
- */
- *refp = whp->ref;
-
-err:
- WT_TRET(__wt_hazard_weak_clear(session, whpp));
- return (ret);
-}
diff --git a/src/third_party/wiredtiger/src/support/stat.c b/src/third_party/wiredtiger/src/support/stat.c
index ecf4d230568..7d9bd538f32 100644
--- a/src/third_party/wiredtiger/src/support/stat.c
+++ b/src/third_party/wiredtiger/src/support/stat.c
@@ -1581,9 +1581,7 @@ static const char *const __stats_connection_desc[] = {
"transaction: transaction rollback to stable currently running",
"transaction: transaction walk of concurrent sessions",
"transaction: transactions committed",
- "transaction: transactions committed with one or more updates resolved through the slow path",
"transaction: transactions rolled back",
- "transaction: transactions rolled back with one or more updates resolved through the slow path",
"transaction: update conflicts",
};
@@ -2141,9 +2139,7 @@ __wt_stat_connection_clear_single(WT_CONNECTION_STATS *stats)
/* not clearing txn_rollback_to_stable_running */
stats->txn_walk_sessions = 0;
stats->txn_commit = 0;
- stats->txn_commit_slow_resolved = 0;
stats->txn_rollback = 0;
- stats->txn_rollback_slow_resolved = 0;
stats->txn_update_conflict = 0;
}
@@ -2723,9 +2719,7 @@ __wt_stat_connection_aggregate(WT_CONNECTION_STATS **from, WT_CONNECTION_STATS *
to->txn_rollback_to_stable_running += WT_STAT_READ(from, txn_rollback_to_stable_running);
to->txn_walk_sessions += WT_STAT_READ(from, txn_walk_sessions);
to->txn_commit += WT_STAT_READ(from, txn_commit);
- to->txn_commit_slow_resolved += WT_STAT_READ(from, txn_commit_slow_resolved);
to->txn_rollback += WT_STAT_READ(from, txn_rollback);
- to->txn_rollback_slow_resolved += WT_STAT_READ(from, txn_rollback_slow_resolved);
to->txn_update_conflict += WT_STAT_READ(from, txn_update_conflict);
}
diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c
index 9fed0b7cc6b..e0327698eb6 100644
--- a/src/third_party/wiredtiger/src/txn/txn.c
+++ b/src/third_party/wiredtiger/src/txn/txn.c
@@ -760,8 +760,6 @@ __wt_txn_release(WT_SESSION_IMPL *session)
txn->flags = 0;
txn->prepare_timestamp = WT_TS_NONE;
- txn->resolve_weak_hazard_updates = false;
-
/* Clear operation timer. */
txn->operation_timeout_us = 0;
}
@@ -1108,11 +1106,11 @@ err:
}
/*
- * __txn_search_uncommitted_op --
- * Search for an operation's uncommitted update.
+ * __txn_search_prepared_op --
+ * Search for an operation's prepared update.
*/
static int
-__txn_search_uncommitted_op(
+__txn_search_prepared_op(
WT_SESSION_IMPL *session, WT_TXN_OP *op, WT_CURSOR **cursorp, WT_UPDATE **updp)
{
WT_CURSOR *cursor;
@@ -1206,7 +1204,7 @@ __txn_resolve_prepared_op(WT_SESSION_IMPL *session, WT_TXN_OP *op, bool commit,
fix_upd = tombstone = NULL;
upd_appended = false;
- WT_RET(__txn_search_uncommitted_op(session, op, cursorp, &upd));
+ WT_RET(__txn_search_prepared_op(session, op, cursorp, &upd));
if (commit)
__wt_verbose(session, WT_VERB_TRANSACTION,
@@ -1498,7 +1496,7 @@ __txn_commit_timestamps_assert(WT_SESSION_IMPL *session)
/* Search for prepared updates. */
if (F_ISSET(txn, WT_TXN_PREPARE))
- WT_ERR(__txn_search_uncommitted_op(session, op, &cursor, &upd));
+ WT_ERR(__txn_search_prepared_op(session, op, &cursor, &upd));
else
upd = op->u.op_upd;
@@ -1612,82 +1610,6 @@ __txn_mod_compare(const void *a, const void *b)
}
/*
- * __wt_txn_op_list_clear_weak_hazard --
- * Walk the transaction op list clearing all the weak hazard pointers.
- */
-int
-__wt_txn_op_list_clear_weak_hazard(WT_SESSION_IMPL *session)
-{
- WT_DECL_RET;
- WT_TXN *txn;
- WT_TXN_OP *op;
- u_int i;
-
- txn = session->txn;
- for (i = 0, op = txn->mod; i < txn->mod_count; i++, op++) {
- if (op->whp != NULL)
- WT_WITH_BTREE(session, op->btree, ret = __wt_hazard_weak_clear(session, &op->whp));
- WT_RET(ret);
- }
- return (0);
-}
-
-/*
- * __txn_resolve_weak_hazard_updates --
- * Resolve an uncommitted op if needed. Fetches the latest update pointer to be used as part of
- * the transaction operation.
- */
-static int
-__txn_resolve_weak_hazard_updates(
- WT_SESSION_IMPL *session, WT_TXN_OP *op, WT_CURSOR **cursorp, WT_REF **refp)
-{
- WT_DECL_RET;
- WT_REF *ref;
- WT_TXN *txn;
- WT_UPDATE *upd;
-
- *refp = NULL;
-
- ref = NULL;
- txn = session->txn;
-
- /* If we disabled resolution for some reason, or these are unsupported cases - do nothing. */
- if (!txn->resolve_weak_hazard_updates)
- return (0);
- if (WT_IS_METADATA(op->btree->dhandle) ||
- (op->type != WT_TXN_OP_BASIC_COL && op->type != WT_TXN_OP_INMEM_COL &&
- op->type != WT_TXN_OP_BASIC_ROW && op->type != WT_TXN_OP_INMEM_ROW))
- return (0);
-
- /*
- * Try to upgrade the weak pointer. If successful the page is still in memory and we are holding
- * a strong hazard pointer. The caller will have to clear the strong hazard pointer when it is
- * done using the page.
- */
- WT_WITH_BTREE(session, op->btree, ret = __wt_hazard_weak_upgrade(session, &op->whp, &ref));
- if (ret == 0) {
- *refp = ref;
- return (0);
- }
-
- /* We could not upgrade the weak pointer, resolve the reference by searching for the update. */
- if (ret == EBUSY) {
- WT_SAVE_DHANDLE(session, ret = __txn_search_uncommitted_op(session, op, cursorp, &upd));
- WT_RET(ret);
-
- /*
- * Since we are not evicting yet and we don't resolve updates on keys with multiple updates
- * we expect to find the update we already have.
- */
- WT_ASSERT(session, op->u.op_upd == upd);
-
- op->u.op_upd = upd;
- }
-
- return (ret);
-}
-
-/*
* __wt_txn_commit --
* Commit the current transaction.
*/
@@ -1698,7 +1620,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
WT_CONNECTION_IMPL *conn;
WT_CURSOR *cursor;
WT_DECL_RET;
- WT_REF *ref;
WT_TXN *txn;
WT_TXN_GLOBAL *txn_global;
WT_TXN_OP *op;
@@ -1710,11 +1631,10 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
#ifdef HAVE_DIAGNOSTIC
u_int prepare_count;
#endif
- bool locked, prepare, readonly, slow_resolved, update_durable_ts;
+ bool locked, prepare, readonly, update_durable_ts;
conn = S2C(session);
cursor = NULL;
- ref = NULL;
txn = session->txn;
txn_global = &conn->txn_global;
#ifdef HAVE_DIAGNOSTIC
@@ -1723,7 +1643,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
locked = false;
prepare = F_ISSET(txn, WT_TXN_PREPARE);
readonly = txn->mod_count == 0;
- slow_resolved = false;
/* Permit the commit if the transaction failed, but was read-only. */
WT_ASSERT(session, F_ISSET(txn, WT_TXN_RUNNING));
@@ -1849,26 +1768,9 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
case WT_TXN_OP_BASIC_ROW:
case WT_TXN_OP_INMEM_COL:
case WT_TXN_OP_INMEM_ROW:
- if (!prepare) {
- /*
- * The page carrying the updates could have been evicted already. We will need to
- * fix the update pointer in the transaction op in such a case. If the resolution
- * returns a reference, the page was not evicted and we hold a strong hazard pointer
- * that we need to clear after the use. For testing purposes assert if resolution
- * fails. On successful slow resolution, after the cursor moves to resolve another
- * update, nothing prevents this update from getting evicted. We will have to deal
- * with that in the future work.
- */
- ret = __txn_resolve_weak_hazard_updates(session, op, &cursor, &ref);
- WT_ERR_ASSERT(
- session, ret == 0, ret, "Failed to resolve an update during txn_commit");
-
- if (ref == NULL)
- slow_resolved = true;
- else
- WT_WITH_BTREE(session, op->btree, ret = __wt_hazard_clear(session, ref));
- upd = op->u.op_upd;
+ upd = op->u.op_upd;
+ if (!prepare) {
/*
* Switch reserved operations to abort to simplify obsolete update list truncation.
*/
@@ -1878,6 +1780,14 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
}
/*
+ * For now just confirm that each operation has a weak hazard pointer and clear it
+ * before proceeding.
+ */
+ if ((op->type == WT_TXN_OP_BASIC_ROW || op->type == WT_TXN_OP_INMEM_ROW) &&
+ !WT_IS_METADATA(op->btree->dhandle) && upd->type != WT_UPDATE_RESERVE)
+ WT_ERR(__wt_hazard_weak_clear(session, op));
+
+ /*
* Don't reset the timestamp of the history store records with history store
* transaction timestamp. Those records should already have the original time window
* when they are inserted into the history store.
@@ -1918,13 +1828,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
WT_CLEAR(cursor->key);
}
- /*
- * This is temporary till we fix accounting for cached cursors in python testing: Don't cache
- * the cursor that was opened for slow resolution of the updates.
- */
- if (cursor != NULL && slow_resolved)
- F_CLR(cursor, WT_CURSTD_CACHEABLE);
-
if (cursor != NULL) {
WT_ERR(cursor->close(cursor));
cursor = NULL;
@@ -2023,9 +1926,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
"durable timestamp");
}
- if (slow_resolved)
- WT_STAT_CONN_INCR(session, txn_commit_slow_resolved);
-
return (0);
err:
@@ -2094,12 +1994,6 @@ __wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[])
WT_RET(__wt_session_copy_values(session));
}
- /* For now we will decide not to resolve uncommitted updates on prepare. */
- if (txn->resolve_weak_hazard_updates) {
- WT_RET(__wt_txn_op_list_clear_weak_hazard(session));
- txn->resolve_weak_hazard_updates = false;
- }
-
for (i = 0, op = txn->mod; i < txn->mod_count; i++, op++) {
/* Assert it's not an update to the history store file. */
WT_ASSERT(session, S2C(session)->cache->hs_fileid == 0 || !WT_IS_HS(op->btree->dhandle));
@@ -2136,6 +2030,14 @@ __wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[])
break;
}
+ /*
+ * For now just confirm that each operation has a weak hazard pointer and clear it
+ * before proceeding.
+ */
+ if ((op->type == WT_TXN_OP_BASIC_ROW || op->type == WT_TXN_OP_INMEM_ROW) &&
+ !WT_IS_METADATA(op->btree->dhandle) && upd->type != WT_UPDATE_RESERVE)
+ WT_RET(__wt_hazard_weak_clear(session, op));
+
++prepared_updates;
/* Set prepare timestamp. */
@@ -2207,7 +2109,6 @@ __wt_txn_rollback(WT_SESSION_IMPL *session, const char *cfg[])
{
WT_CURSOR *cursor;
WT_DECL_RET;
- WT_REF *ref;
WT_TXN *txn;
WT_TXN_OP *op;
WT_UPDATE *upd;
@@ -2215,17 +2116,15 @@ __wt_txn_rollback(WT_SESSION_IMPL *session, const char *cfg[])
#ifdef HAVE_DIAGNOSTIC
u_int prepare_count;
#endif
- bool prepare, readonly, slow_resolved;
+ bool prepare, readonly;
cursor = NULL;
- ref = NULL;
txn = session->txn;
#ifdef HAVE_DIAGNOSTIC
prepare_count = 0;
#endif
prepare = F_ISSET(txn, WT_TXN_PREPARE);
readonly = txn->mod_count == 0;
- slow_resolved = false;
WT_ASSERT(session, F_ISSET(txn, WT_TXN_RUNNING));
@@ -2260,25 +2159,16 @@ __wt_txn_rollback(WT_SESSION_IMPL *session, const char *cfg[])
case WT_TXN_OP_BASIC_ROW:
case WT_TXN_OP_INMEM_COL:
case WT_TXN_OP_INMEM_ROW:
+ upd = op->u.op_upd;
+
if (!prepare) {
/*
- * The page carrying the updates could have been evicted already. We will need to
- * fix the update pointer in the transaction op in such a case. If the resolution
- * returns a reference, the page was not evicted and we hold a strong hazard pointer
- * that we need to clear after the use. For testing purposes assert if resolution
- * fails. On successful slow resolution, after the cursor moves to resolve another
- * update, nothing prevents this update from getting evicted. We will have to deal
- * with that in the future work.
+ * For now just confirm that each operation has a weak hazard pointer and clear it
+ * before proceeding.
*/
- ret = __txn_resolve_weak_hazard_updates(session, op, &cursor, &ref);
- WT_RET_ASSERT(
- session, ret == 0, ret, "Failed to resolve an update during txn_rollback");
-
- if (ref == NULL)
- slow_resolved = true;
- else
- WT_WITH_BTREE(session, op->btree, ret = __wt_hazard_clear(session, ref));
- upd = op->u.op_upd;
+ if ((op->type == WT_TXN_OP_BASIC_ROW || op->type == WT_TXN_OP_INMEM_ROW) &&
+ !WT_IS_METADATA(op->btree->dhandle) && upd->type != WT_UPDATE_RESERVE)
+ WT_TRET(__wt_hazard_weak_clear(session, op));
if (S2C(session)->cache->hs_fileid != 0 &&
op->btree->id == S2C(session)->cache->hs_fileid)
@@ -2321,9 +2211,6 @@ __wt_txn_rollback(WT_SESSION_IMPL *session, const char *cfg[])
txn->prepare_count = 0;
#endif
- if (slow_resolved)
- WT_STAT_CONN_INCR(session, txn_rollback_slow_resolved);
-
if (cursor != NULL) {
WT_TRET(cursor->close(cursor));
cursor = NULL;
diff --git a/src/third_party/wiredtiger/src/txn/txn_log.c b/src/third_party/wiredtiger/src/txn/txn_log.c
index 9c2f8c79a86..7b5dd71f424 100644
--- a/src/third_party/wiredtiger/src/txn/txn_log.c
+++ b/src/third_party/wiredtiger/src/txn/txn_log.c
@@ -254,8 +254,6 @@ __wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
WT_ITEM *logrec;
WT_TXN *txn;
WT_TXN_OP *op;
- WT_UPDATE *upd;
- bool set_weak_hazard;
uint32_t fileid;
@@ -269,33 +267,12 @@ __wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
op = txn->mod + txn->mod_count - 1;
fileid = op->btree->id;
- /*
- * We take a weak hazard pointer for an operation if this transaction is marked to be resolving
- * the uncommitted updates. This is not supported on the metadata, and is only supported on the
- * row and column store operations.
- */
- set_weak_hazard = (txn->resolve_weak_hazard_updates && !WT_IS_METADATA(op->btree->dhandle) &&
- (op->type == WT_TXN_OP_BASIC_COL || op->type == WT_TXN_OP_INMEM_COL ||
- op->type == WT_TXN_OP_BASIC_ROW || op->type == WT_TXN_OP_INMEM_ROW));
-
- /*
- * This is temporary till we support more cases for resolving uncommitted updates: If there are
- * older updates to this key by the same transaction, or if there are truncates, for now decide
- * not to proceed with resolving uncommitted updates. If we decide to stop resolving the
- * uncommitted updates, we need to clear the weak hazard pointers for the operations that have
- * taken one.
- */
- upd = op->u.op_upd;
- if (set_weak_hazard && upd != NULL && upd->next != NULL &&
- (upd->next->txnid == txn->id || F_ISSET(upd->next, WT_UPDATE_RESTORED_FAST_TRUNCATE))) {
- WT_RET(__wt_txn_op_list_clear_weak_hazard(session));
- set_weak_hazard = txn->resolve_weak_hazard_updates = false;
- }
-
/* Set the weak hazard pointer for this update. */
- if (set_weak_hazard) {
- WT_ASSERT(session, cbt != NULL);
- WT_RET(__wt_hazard_weak_set(session, cbt->ref, op));
+ if ((op->type == WT_TXN_OP_BASIC_ROW || op->type == WT_TXN_OP_INMEM_ROW)) {
+ if (!WT_IS_METADATA(op->btree->dhandle)) {
+ WT_ASSERT(session, cbt != NULL);
+ WT_RET(__wt_hazard_weak_set(session, cbt->ref, op));
+ }
}
if (!FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED) ||