summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp')
-rw-r--r--src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp42
1 files changed, 18 insertions, 24 deletions
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 69b5a111e2b..4cb90818562 100644
--- a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
@@ -29,8 +29,6 @@
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kQuery
-#include "mongo/platform/basic.h"
-
#include "mongo/db/pipeline/process_interface/shardsvr_process_interface.h"
#include <fmt/format.h>
@@ -51,7 +49,7 @@
#include "mongo/s/cluster_commands_helpers.h"
#include "mongo/s/cluster_write.h"
#include "mongo/s/query/document_source_merge_cursors.h"
-#include "mongo/s/router.h"
+#include "mongo/s/router_role.h"
#include "mongo/s/stale_shard_version_helpers.h"
namespace mongo {
@@ -76,14 +74,11 @@ void ShardServerProcessInterface::checkRoutingInfoEpochOrThrow(
catalogCache->invalidateShardOrEntireCollectionEntryForShardedCollection(
nss, targetCollectionVersion, shardId);
- const auto routingInfo =
- uassertStatusOK(catalogCache->getCollectionRoutingInfo(expCtx->opCtx, nss));
-
- const auto foundVersion =
- routingInfo.isSharded() ? routingInfo.getVersion() : ChunkVersion::UNSHARDED();
+ const auto cm = uassertStatusOK(catalogCache->getCollectionRoutingInfo(expCtx->opCtx, nss));
+ auto foundVersion = cm.isSharded() ? cm.getVersion() : ChunkVersion::UNSHARDED();
- uassert(StaleEpochInfo(nss),
- str::stream() << "Could not act as router for " << nss.ns() << ", wanted "
+ uassert(StaleEpochInfo(nss, targetCollectionVersion, foundVersion),
+ str::stream() << "Could not act as router for " << nss.ns() << ", received "
<< targetCollectionVersion.toString() << ", but found "
<< foundVersion.toString(),
foundVersion.isSameCollection(targetCollectionVersion));
@@ -104,20 +99,20 @@ boost::optional<Document> ShardServerProcessInterface::lookupSingleDocument(
return doLookupSingleDocument(expCtx, nss, collectionUUID, documentKey, std::move(opts));
}
-Status ShardServerProcessInterface::insert(const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const NamespaceString& ns,
- std::vector<BSONObj>&& objs,
- const WriteConcernOptions& wc,
- boost::optional<OID> targetEpoch) {
+Status ShardServerProcessInterface::insert(
+ const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ const NamespaceString& ns,
+ std::unique_ptr<write_ops::InsertCommandRequest> insertCommand,
+ const WriteConcernOptions& wc,
+ boost::optional<OID> targetEpoch) {
BatchedCommandResponse response;
BatchWriteExecStats stats;
- BatchedCommandRequest insertCommand(
- buildInsertOp(ns, std::move(objs), expCtx->bypassDocumentValidation));
+ BatchedCommandRequest batchInsertCommand(std::move(insertCommand));
- insertCommand.setWriteConcern(wc.toBSON());
+ batchInsertCommand.setWriteConcern(wc.toBSON());
- cluster::write(expCtx->opCtx, insertCommand, &stats, &response, targetEpoch);
+ cluster::write(expCtx->opCtx, batchInsertCommand, &stats, &response, targetEpoch);
return response.toStatus();
}
@@ -125,7 +120,7 @@ Status ShardServerProcessInterface::insert(const boost::intrusive_ptr<Expression
StatusWith<MongoProcessInterface::UpdateResult> ShardServerProcessInterface::update(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
const NamespaceString& ns,
- BatchedObjects&& batch,
+ std::unique_ptr<write_ops::UpdateCommandRequest> updateCommand,
const WriteConcernOptions& wc,
UpsertType upsert,
bool multi,
@@ -133,11 +128,10 @@ StatusWith<MongoProcessInterface::UpdateResult> ShardServerProcessInterface::upd
BatchedCommandResponse response;
BatchWriteExecStats stats;
- BatchedCommandRequest updateCommand(buildUpdateOp(expCtx, ns, std::move(batch), upsert, multi));
-
- updateCommand.setWriteConcern(wc.toBSON());
+ BatchedCommandRequest batchUpdateCommand(std::move(updateCommand));
+ batchUpdateCommand.setWriteConcern(wc.toBSON());
- cluster::write(expCtx->opCtx, updateCommand, &stats, &response, targetEpoch);
+ cluster::write(expCtx->opCtx, batchUpdateCommand, &stats, &response, targetEpoch);
if (auto status = response.toStatus(); status != Status::OK()) {
return status;