summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline
diff options
context:
space:
mode:
authorFernando Lisboa <fernando.lisboa@mongodb.com>2022-06-27 14:07:15 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-27 15:41:20 +0000
commite7fcd61d6d54192c59ac08c54959e65c33b9bea3 (patch)
tree8839594f412f657e6461f0ea373680b14258246d /src/mongo/db/pipeline
parent2755ae704740a4fad23d596b55e29095a776fe56 (diff)
downloadmongo-e7fcd61d6d54192c59ac08c54959e65c33b9bea3.tar.gz
SERVER-66802 Make ReplicaSetNodeProcessInterface::createCollection take in DatabaseName
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r--src/mongo/db/pipeline/document_source_out.cpp7
-rw-r--r--src/mongo/db/pipeline/process_interface/mongo_process_interface.h2
-rw-r--r--src/mongo/db/pipeline/process_interface/mongos_process_interface.h2
-rw-r--r--src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.cpp5
-rw-r--r--src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h2
-rw-r--r--src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp7
-rw-r--r--src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.h2
-rw-r--r--src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp9
-rw-r--r--src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h2
-rw-r--r--src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h2
10 files changed, 22 insertions, 18 deletions
diff --git a/src/mongo/db/pipeline/document_source_out.cpp b/src/mongo/db/pipeline/document_source_out.cpp
index cafce106b28..ed36b5e1b71 100644
--- a/src/mongo/db/pipeline/document_source_out.cpp
+++ b/src/mongo/db/pipeline/document_source_out.cpp
@@ -113,8 +113,9 @@ void DocumentSourceOut::initialize() {
// to be the target collection once we are done.
// Note that this temporary collection name is used by MongoMirror and thus should not be
// changed without consultation.
- _tempNs = NamespaceString(str::stream()
- << outputNs.dbName().toString() << ".tmp.agg_out." << UUID::gen());
+ _tempNs = NamespaceString(outputNs.tenantId(),
+ str::stream() << outputNs.dbName().toString() << ".tmp.agg_out."
+ << UUID::gen());
// Save the original collection options and index specs so we can check they didn't change
// during computation.
@@ -139,7 +140,7 @@ void DocumentSourceOut::initialize() {
cmd.appendElementsUnique(_originalOutOptions);
pExpCtx->mongoProcessInterface->createCollection(
- pExpCtx->opCtx, _tempNs.dbName().toString(), cmd.done());
+ pExpCtx->opCtx, _tempNs.dbName(), cmd.done());
}
CurOpFailpointHelpers::waitWhileFailPointEnabled(
diff --git a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
index 19477adf8c9..918b7ed1257 100644
--- a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
@@ -255,7 +255,7 @@ public:
* the primary shard of 'dbName'.
*/
virtual void createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) = 0;
/**
diff --git a/src/mongo/db/pipeline/process_interface/mongos_process_interface.h b/src/mongo/db/pipeline/process_interface/mongos_process_interface.h
index 82eedfa6dec..2eeccbef734 100644
--- a/src/mongo/db/pipeline/process_interface/mongos_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/mongos_process_interface.h
@@ -146,7 +146,7 @@ public:
}
void createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) final {
MONGO_UNREACHABLE;
}
diff --git a/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.cpp b/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.cpp
index 0467f938fae..2ba7cfcc664 100644
--- a/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.cpp
@@ -190,9 +190,10 @@ void NonShardServerProcessInterface::renameIfOptionsAndIndexesHaveNotChanged(
}
void NonShardServerProcessInterface::createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) {
- uassertStatusOK(mongo::createCollection(opCtx, dbName, cmdObj));
+ // TODO SERVER-67409 change mongo::createCollection to take in DatabaseName
+ uassertStatusOK(mongo::createCollection(opCtx, dbName.toStringWithTenantId(), cmdObj));
}
void NonShardServerProcessInterface::dropCollection(OperationContext* opCtx,
diff --git a/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h b/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h
index ccbe90205c9..9d3eb31c31c 100644
--- a/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h
@@ -108,7 +108,7 @@ public:
const std::list<BSONObj>& originalIndexes) override;
void createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) override;
void dropCollection(OperationContext* opCtx, const NamespaceString& collection) override;
diff --git a/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp b/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp
index a4deb9556cc..a9620f9e21b 100644
--- a/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp
@@ -142,13 +142,14 @@ void ReplicaSetNodeProcessInterface::renameIfOptionsAndIndexesHaveNotChanged(
}
void ReplicaSetNodeProcessInterface::createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) {
- NamespaceString dbNs{dbName};
+ NamespaceString dbNs = NamespaceString(dbName, StringData(""));
if (_canWriteLocally(opCtx, dbNs)) {
return NonShardServerProcessInterface::createCollection(opCtx, dbName, cmdObj);
}
- auto ns = CommandHelpers::parseNsCollectionRequired(dbName, cmdObj);
+ // TODO SERVER-67519 change CommandHelpers::parseNsCollectionRequired to take in DatabaseName
+ auto ns = CommandHelpers::parseNsCollectionRequired(dbName.toStringWithTenantId(), cmdObj);
uassertStatusOK(_executeCommandOnPrimary(opCtx, ns, cmdObj));
}
diff --git a/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.h b/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.h
index c61f654e844..465cad53191 100644
--- a/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.h
@@ -76,7 +76,7 @@ public:
const BSONObj& originalCollectionOptions,
const std::list<BSONObj>& originalIndexes);
void createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj);
void dropCollection(OperationContext* opCtx, const NamespaceString& collection);
void createIndexesOnEmptyCollection(OperationContext* opCtx,
diff --git a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
index be36893b9d5..c964ae57382 100644
--- a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
@@ -286,17 +286,18 @@ std::list<BSONObj> ShardServerProcessInterface::getIndexSpecs(OperationContext*
}
void ShardServerProcessInterface::createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) {
- auto cachedDbInfo =
- uassertStatusOK(Grid::get(opCtx)->catalogCache()->getDatabase(opCtx, dbName));
+ auto cachedDbInfo = uassertStatusOK(
+ Grid::get(opCtx)->catalogCache()->getDatabase(opCtx, dbName.toStringWithTenantId()));
BSONObjBuilder finalCmdBuilder(cmdObj);
finalCmdBuilder.append(WriteConcernOptions::kWriteConcernField,
opCtx->getWriteConcern().toBSON());
BSONObj finalCmdObj = finalCmdBuilder.obj();
+ // TODO SERVER-67411 change executeCommandAgainstDatabasePrimary to take in DatabaseName
auto response =
executeCommandAgainstDatabasePrimary(opCtx,
- dbName,
+ dbName.toStringWithTenantId(),
std::move(cachedDbInfo),
finalCmdObj,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
diff --git a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h
index f6026f6ef3a..26378535dab 100644
--- a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h
@@ -110,7 +110,7 @@ public:
const BSONObj& originalCollectionOptions,
const std::list<BSONObj>& originalIndexes) final;
void createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) final;
void createIndexesOnEmptyCollection(OperationContext* opCtx,
const NamespaceString& ns,
diff --git a/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h
index 3fe1430ac72..80121dfecac 100644
--- a/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h
@@ -138,7 +138,7 @@ public:
}
void createCollection(OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) override {
MONGO_UNREACHABLE;
}