summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2023-04-03 11:26:23 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-04-03 01:41:52 +0000
commit618353760484f1dfe231676aaf33eb5ff73f7458 (patch)
tree832557140184123b0bcd1804a85e9caa3bd9c4d5
parent9b200f4c1d6b8fa118e98571e38ec7bede2f07d2 (diff)
downloadmongo-618353760484f1dfe231676aaf33eb5ff73f7458.tar.gz
Import wiredtiger: b32ec77d65b3e5e8ce2d3acf4918a8df014c8e69 from branch mongodb-4.4
ref: c5b5e47d2c..b32ec77d65 for: 4.4.20 WT-9926 A crash during startup from backup can lose metadata (v4.4 Backport)
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/meta/meta_turtle.c7
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_ckpt.c9
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_recover.c3
4 files changed, 18 insertions, 3 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index d89f190d17f..43ded9f7593 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-4.4",
- "commit": "c5b5e47d2c3023a41782be617dad72aa13ffa86c"
+ "commit": "b32ec77d65b3e5e8ce2d3acf4918a8df014c8e69"
}
diff --git a/src/third_party/wiredtiger/src/meta/meta_turtle.c b/src/third_party/wiredtiger/src/meta/meta_turtle.c
index 309c80eaa05..a2b85285990 100644
--- a/src/third_party/wiredtiger/src/meta/meta_turtle.c
+++ b/src/third_party/wiredtiger/src/meta/meta_turtle.c
@@ -324,8 +324,11 @@ __wt_turtle_init(WT_SESSION_IMPL *session)
WT_RET(ret);
}
- /* Remove the backup files, we'll never read them again. */
- return (__wt_backup_file_remove(session));
+ /*
+ * We used to remove the backup file here. But we cannot do that until the metadata is fully
+ * synced to disk after recovery.
+ */
+ return (ret);
}
/*
diff --git a/src/third_party/wiredtiger/src/txn/txn_ckpt.c b/src/third_party/wiredtiger/src/txn/txn_ckpt.c
index e4ab6778af8..be072499e36 100644
--- a/src/third_party/wiredtiger/src/txn/txn_ckpt.c
+++ b/src/third_party/wiredtiger/src/txn/txn_ckpt.c
@@ -1352,6 +1352,15 @@ __checkpoint_lock_dirty_tree_int(WT_SESSION_IMPL *session, bool is_checkpoint, b
is_wt_ckpt = WT_PREFIX_MATCH(ckpt->name, WT_CHECKPOINT);
/*
+ * If we are restarting from a backup and we're in recovery do not delete any checkpoints.
+ * In the event of a crash we may need to restart from the backup and all checkpoints that
+ * were in the backup file must remain.
+ */
+ if (F_ISSET(conn, WT_CONN_RECOVERING) && F_ISSET(conn, WT_CONN_WAS_BACKUP)) {
+ F_CLR(ckpt, WT_CKPT_DELETE);
+ continue;
+ }
+ /*
* If there is a hot backup, don't delete any WiredTiger checkpoint that could possibly have
* been created before the backup started. Fail if trying to delete any other named
* checkpoint.
diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c
index 02d7d5e7a05..1036b761c37 100644
--- a/src/third_party/wiredtiger/src/txn/txn_recover.c
+++ b/src/third_party/wiredtiger/src/txn/txn_recover.c
@@ -1082,6 +1082,9 @@ done:
*/
WT_ERR(session->iface.checkpoint(&session->iface, "force=1"));
+ /* Remove any backup file now that metadata has been synced. */
+ WT_ERR(__wt_backup_file_remove(session));
+
/*
* Update the open dhandles write generations and base write generation with the connection's
* base write generation because the recovery checkpoint writes the pages to disk with new write