summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/config/configsvr_run_restore_command.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s/config/configsvr_run_restore_command.cpp')
-rw-r--r--src/mongo/db/s/config/configsvr_run_restore_command.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/mongo/db/s/config/configsvr_run_restore_command.cpp b/src/mongo/db/s/config/configsvr_run_restore_command.cpp
index 166c10a4e70..22e3f7b2985 100644
--- a/src/mongo/db/s/config/configsvr_run_restore_command.cpp
+++ b/src/mongo/db/s/config/configsvr_run_restore_command.cpp
@@ -73,6 +73,25 @@ ShouldRestoreDocument shouldRestoreDocument(OperationContext* opCtx,
: ShouldRestoreDocument::kNo;
}
+std::set<std::string> getDatabasesToRestore(OperationContext* opCtx) {
+ auto findRequest = FindCommandRequest(NamespaceString::kConfigsvrRestoreNamespace);
+
+ std::set<std::string> databasesToRestore;
+ DBDirectClient client(opCtx);
+ auto it = client.find(findRequest);
+ while (it->more()) {
+ const auto doc = it->next();
+ if (!doc.hasField("ns")) {
+ continue;
+ }
+
+ NamespaceString nss(doc.getStringField("ns"));
+ databasesToRestore.emplace(nss.db());
+ }
+
+ return databasesToRestore;
+}
+
// Modifications to this map should add new testing in 'sharded_backup_restore.js'.
// { config collection namespace -> ( optional nss field name, optional UUID field name ) }
const stdx::unordered_map<NamespaceString,
@@ -146,7 +165,7 @@ public:
// Keeps track of database names for collections restored. Databases with no collections
// restored will have their entries removed in the config collections.
- std::set<std::string> databasesRestored;
+ std::set<std::string> databasesRestored = getDatabasesToRestore(opCtx);
for (const auto& collectionEntry : kCollectionEntries) {
const NamespaceString& nss = collectionEntry.first;
@@ -200,10 +219,6 @@ public:
"doc"_attr = doc,
"shouldRestore"_attr = shouldRestore);
- if (shouldRestore == ShouldRestoreDocument::kYes && docNss) {
- databasesRestored.insert(docNss->db().toString());
- }
-
if (shouldRestore == ShouldRestoreDocument::kYes ||
shouldRestore == ShouldRestoreDocument::kMaybe) {
continue;