summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/config/configsvr_run_restore_command.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2022-08-03 16:38:12 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-03 17:53:48 +0000
commit53f983cb4933e4bd1cd32b5c5c5d9f907b1c65ef (patch)
tree8a0aedfd3eb2ff6dac274d761d5421a387f7ca1a /src/mongo/db/s/config/configsvr_run_restore_command.cpp
parent557741f2a966918792ddb22cc276a7628bc8a215 (diff)
downloadmongo-53f983cb4933e4bd1cd32b5c5c5d9f907b1c65ef.tar.gz
SERVER-68513 The _configsvrRunRestore command should restore databases with unsharded collections
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 24fb363453e..9d18acc9fec 100644
--- a/src/mongo/db/s/config/configsvr_run_restore_command.cpp
+++ b/src/mongo/db/s/config/configsvr_run_restore_command.cpp
@@ -75,6 +75,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,
@@ -148,7 +167,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;
@@ -202,10 +221,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;