summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/txn
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/txn')
-rw-r--r--src/third_party/wiredtiger/src/txn/txn.c43
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_ckpt.c1
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_recover.c14
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c15
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_timestamp.c6
5 files changed, 70 insertions, 9 deletions
diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c
index ce0e736226c..de902b8d442 100644
--- a/src/third_party/wiredtiger/src/txn/txn.c
+++ b/src/third_party/wiredtiger/src/txn/txn.c
@@ -139,6 +139,49 @@ __wt_txn_release_snapshot(WT_SESSION_IMPL *session)
}
/*
+ * __wt_txn_active --
+ * Check if a transaction is still active. If not, it is either committed, prepared, or rolled
+ * back. It is possible that we race with commit, prepare or rollback and a transaction is still
+ * active before the start of the call is eventually reported as resolved.
+ */
+bool
+__wt_txn_active(WT_SESSION_IMPL *session, uint64_t txnid)
+{
+ WT_CONNECTION_IMPL *conn;
+ WT_TXN_GLOBAL *txn_global;
+ WT_TXN_SHARED *s;
+ uint64_t oldest_id;
+ uint32_t i, session_cnt;
+ bool active;
+
+ conn = S2C(session);
+ txn_global = &conn->txn_global;
+ active = true;
+
+ /* We're going to scan the table: wait for the lock. */
+ __wt_readlock(session, &txn_global->rwlock);
+ oldest_id = txn_global->oldest_id;
+
+ if (WT_TXNID_LT(txnid, oldest_id)) {
+ active = false;
+ goto done;
+ }
+
+ /* Walk the array of concurrent transactions. */
+ WT_ORDERED_READ(session_cnt, conn->session_cnt);
+ for (i = 0, s = txn_global->txn_shared_list; i < session_cnt; i++, s++) {
+ /* If the transaction is in the list, it is uncommitted. */
+ if (s->id == txnid)
+ goto done;
+ }
+
+ active = false;
+done:
+ __wt_readunlock(session, &txn_global->rwlock);
+ return (active);
+}
+
+/*
* __txn_get_snapshot_int --
* Allocate a snapshot, optionally update our shared txn ids.
*/
diff --git a/src/third_party/wiredtiger/src/txn/txn_ckpt.c b/src/third_party/wiredtiger/src/txn/txn_ckpt.c
index 54a13cedff0..8178e593f6b 100644
--- a/src/third_party/wiredtiger/src/txn/txn_ckpt.c
+++ b/src/third_party/wiredtiger/src/txn/txn_ckpt.c
@@ -1580,6 +1580,7 @@ __wt_checkpoint_tree_reconcile_update(WT_SESSION_IMPL *session, WT_TIME_AGGREGAT
WT_CKPT_FOREACH (ckptbase, ckpt)
if (F_ISSET(ckpt, WT_CKPT_ADD)) {
ckpt->write_gen = btree->write_gen;
+ ckpt->run_write_gen = btree->run_write_gen;
WT_TIME_AGGREGATE_COPY(&ckpt->ta, ta);
}
}
diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c
index 0b5b7da92c0..6e042fc9b33 100644
--- a/src/third_party/wiredtiger/src/txn/txn_recover.c
+++ b/src/third_party/wiredtiger/src/txn/txn_recover.c
@@ -841,11 +841,19 @@ __wt_txn_recover(WT_SESSION_IMPL *session, const char *cfg[])
WT_ERR(ret);
}
- /* Check whether the history store exists. */
- WT_ERR(__hs_exists(session, metac, cfg, &hs_exists));
-
/* Scan the metadata to find the live files and their IDs. */
WT_ERR(__recovery_file_scan(&r));
+
+ /*
+ * Check whether the history store exists.
+ *
+ * This will open a dhandle on the history store and initialize its write gen so we must ensure
+ * that the connection-wide base write generation is stable at this point. Performing a recovery
+ * file scan will involve updating the connection-wide base write generation so we MUST do this
+ * before checking for the existence of a history store file.
+ */
+ WT_ERR(__hs_exists(session, metac, cfg, &hs_exists));
+
/*
* Clear this out. We no longer need it and it could have been re-allocated when scanning the
* files.
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 75569b8b057..90ec9389deb 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
@@ -267,8 +267,10 @@ __rollback_row_ondisk_fixup_key(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW
hs_stop_durable_ts <= newer_hs_durable_ts || hs_start_ts == hs_stop_durable_ts ||
first_record);
- if (hs_stop_durable_ts < newer_hs_durable_ts)
+ if (hs_stop_durable_ts < newer_hs_durable_ts) {
WT_STAT_CONN_INCR(session, txn_rts_hs_stop_older_than_newer_start);
+ WT_STAT_DATA_INCR(session, txn_rts_hs_stop_older_than_newer_start);
+ }
/*
* Stop processing when we find the newer version value of this key is stable according to
@@ -319,6 +321,8 @@ __rollback_row_ondisk_fixup_key(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW
WT_ERR(__wt_hs_modify(cbt, hs_upd));
WT_STAT_CONN_INCR(session, txn_rts_hs_removed);
WT_STAT_CONN_INCR(session, cache_hs_key_truncate_rts_unstable);
+ WT_STAT_DATA_INCR(session, txn_rts_hs_removed);
+ WT_STAT_DATA_INCR(session, cache_hs_key_truncate_rts_unstable);
}
if (replace) {
@@ -369,10 +373,12 @@ __rollback_row_ondisk_fixup_key(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW
tombstone->next = upd;
upd = tombstone;
WT_STAT_CONN_INCR(session, txn_rts_hs_restore_tombstones);
+ WT_STAT_DATA_INCR(session, txn_rts_hs_restore_tombstones);
}
} else {
WT_ERR(__wt_upd_alloc_tombstone(session, &upd, NULL));
WT_STAT_CONN_INCR(session, txn_rts_keys_removed);
+ WT_STAT_DATA_INCR(session, txn_rts_keys_removed);
__wt_verbose(session, WT_VERB_RTS, "%p: key removed", (void *)key);
}
@@ -385,6 +391,8 @@ __rollback_row_ondisk_fixup_key(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW
WT_ERR(__wt_hs_modify(cbt, hs_upd));
WT_STAT_CONN_INCR(session, txn_rts_hs_removed);
WT_STAT_CONN_INCR(session, cache_hs_key_truncate_rts);
+ WT_STAT_DATA_INCR(session, txn_rts_hs_removed);
+ WT_STAT_DATA_INCR(session, cache_hs_key_truncate_rts);
}
if (0) {
@@ -439,6 +447,7 @@ __rollback_abort_row_ondisk_kv(
__wt_timestamp_to_string(rollback_timestamp, ts_string[4]));
WT_RET(__wt_upd_alloc_tombstone(session, &upd, NULL));
WT_STAT_CONN_INCR(session, txn_rts_sweep_hs_keys);
+ WT_STAT_DATA_INCR(session, txn_rts_sweep_hs_keys);
} else
return (0);
} else if (vpack->tw.durable_start_ts > rollback_timestamp ||
@@ -458,6 +467,7 @@ __rollback_abort_row_ondisk_kv(
*/
WT_RET(__wt_upd_alloc_tombstone(session, &upd, NULL));
WT_STAT_CONN_INCR(session, txn_rts_keys_removed);
+ WT_STAT_DATA_INCR(session, txn_rts_keys_removed);
}
} else if (WT_TIME_WINDOW_HAS_STOP(&vpack->tw) &&
(vpack->tw.durable_stop_ts > rollback_timestamp || prepared)) {
@@ -473,6 +483,7 @@ __rollback_abort_row_ondisk_kv(
upd->start_ts = vpack->tw.start_ts;
F_SET(upd, WT_UPDATE_RESTORED_FROM_DS);
WT_STAT_CONN_INCR(session, txn_rts_keys_restored);
+ WT_STAT_DATA_INCR(session, txn_rts_keys_restored);
__wt_verbose(session, WT_VERB_RTS,
"key restored with commit timestamp: %s, durable timestamp: %s txnid: %" PRIu64
"and removed commit timestamp: %s, durable timestamp: %s, txnid: %" PRIu64
@@ -1055,6 +1066,8 @@ __rollback_to_stable_btree_hs_truncate(WT_SESSION_IMPL *session, uint32_t btree_
WT_ERR(__wt_hs_modify(cbt, hs_upd));
WT_STAT_CONN_INCR(session, txn_rts_hs_removed);
WT_STAT_CONN_INCR(session, cache_hs_key_truncate_rts);
+ WT_STAT_DATA_INCR(session, txn_rts_hs_removed);
+ WT_STAT_DATA_INCR(session, cache_hs_key_truncate_rts);
hs_upd = NULL;
}
WT_ERR_NOTFOUND_OK(ret, false);
diff --git a/src/third_party/wiredtiger/src/txn/txn_timestamp.c b/src/third_party/wiredtiger/src/txn/txn_timestamp.c
index 7cb58074db2..03d5d06cff4 100644
--- a/src/third_party/wiredtiger/src/txn/txn_timestamp.c
+++ b/src/third_party/wiredtiger/src/txn/txn_timestamp.c
@@ -617,11 +617,7 @@ __wt_txn_set_commit_timestamp(WT_SESSION_IMPL *session, wt_timestamp_t commit_ts
__wt_timestamp_to_string(commit_ts, ts_string[0]),
__wt_timestamp_to_string(txn->first_commit_timestamp, ts_string[1]));
- /*
- * FIXME-WT-4780: Disabled to buy time to understand a test failure.
- * WT_RET(__txn_assert_after_reads(
- * session, "commit", commit_ts, NULL));
- */
+ WT_RET(__txn_assert_after_reads(session, "commit", commit_ts, NULL));
} else {
/*
* For a prepared transaction, the commit timestamp should not be less than the prepare