summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/txn/txn_recover.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/txn/txn_recover.c')
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_recover.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c
index e058d08cc17..0f6b99a341e 100644
--- a/src/third_party/wiredtiger/src/txn/txn_recover.c
+++ b/src/third_party/wiredtiger/src/txn/txn_recover.c
@@ -24,6 +24,7 @@ typedef struct {
u_int max_fileid; /* Maximum file ID seen. */
WT_LSN max_lsn; /* Maximum checkpoint LSN seen. */
u_int nfiles; /* Number of files in the metadata. */
+ WT_DECL_TIMESTAMP(max_timestamp)
WT_LSN ckpt_lsn; /* Start LSN for main recovery loop. */
@@ -346,6 +347,7 @@ static int
__recovery_setup_file(WT_RECOVERY *r, const char *uri, const char *config)
{
WT_CONFIG_ITEM cval;
+ WT_DECL_TIMESTAMP(ckpt_timestamp)
WT_LSN lsn;
uint32_t fileid, lsnfile, lsnoffset;
@@ -362,6 +364,29 @@ __recovery_setup_file(WT_RECOVERY *r, const char *uri, const char *config)
r->nfiles = fileid + 1;
}
+#ifdef HAVE_TIMESTAMPS
+ /*
+ * If we're reading the config for the metadata from the turtle file
+ * save the stable timestamp of the last checkpoint for later query.
+ * This gets saved in the connection.
+ */
+ WT_CLEAR(cval);
+ WT_RET_NOTFOUND_OK(__wt_config_getones(r->session,
+ config, "checkpoint_timestamp", &cval));
+ if (cval.len != 0) {
+ __wt_verbose(r->session, WT_VERB_RECOVERY,
+ "%s: Recovery timestamp %.*s",
+ uri, (int)cval.len, cval.str);
+ WT_RET(__wt_txn_parse_timestamp_raw(r->session, "recovery",
+ &ckpt_timestamp, &cval));
+ /*
+ * Keep track of the largest checkpoint timestamp seen.
+ */
+ if (__wt_timestamp_cmp(&ckpt_timestamp, &r->max_timestamp) > 0)
+ __wt_timestamp_set(&r->max_timestamp, &ckpt_timestamp);
+ }
+#endif
+
WT_RET(__wt_strdup(r->session, uri, &r->files[fileid].uri));
WT_RET(
__wt_config_getones(r->session, config, "checkpoint_lsn", &cval));
@@ -472,6 +497,10 @@ __wt_txn_recover(WT_SESSION_IMPL *session)
false, WT_SESSION_NO_LOGGING, &session));
r.session = session;
WT_MAX_LSN(&r.max_lsn);
+#ifdef HAVE_TIMESTAMPS
+ __wt_timestamp_set_zero(&conn->txn_global.recovery_timestamp);
+ __wt_timestamp_set_zero(&r.max_timestamp);
+#endif
F_SET(conn, WT_CONN_RECOVERING);
WT_ERR(__wt_metadata_search(session, WT_METAFILE_URI, &config));
@@ -565,6 +594,15 @@ __wt_txn_recover(WT_SESSION_IMPL *session)
r.files[0].c = NULL;
WT_ERR(metac->close(metac));
+#ifdef HAVE_TIMESTAMPS
+ /*
+ * After recovering the metadata, set the recovery timestamp to the
+ * largest one we recovered.
+ */
+ __wt_timestamp_set(
+ &conn->txn_global.recovery_timestamp, &r.max_timestamp);
+#endif
+
/*
* Now, recover all the files apart from the metadata.
* Pass WT_LOGSCAN_RECOVER so that old logs get truncated.