summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-07-24 15:16:48 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-07-26 10:53:22 -0400
commit86defa9d193f34275af2c4f3c783dffb046182ff (patch)
tree1a57517f940cecc40d99030191a411d7f32283e7 /src/mongo
parent8235ad20a6169b8713ffba991afcd50519e1345b (diff)
downloadmongo-86defa9d193f34275af2c4f3c783dffb046182ff.tar.gz
SERVER-28752 Get rid of BatchedInsertRequest::getIndexTargetingNS
In preparation for removing the Batched Insert/Update/Delete Request parser classes.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/auth/user_cache_invalidator_job.cpp2
-rw-r--r--src/mongo/db/exec/collection_scan.cpp2
-rw-r--r--src/mongo/db/exec/count_scan.cpp2
-rw-r--r--src/mongo/db/exec/delete.cpp8
-rw-r--r--src/mongo/db/exec/distinct_scan.cpp2
-rw-r--r--src/mongo/db/exec/fetch.cpp2
-rw-r--r--src/mongo/db/exec/idhack.cpp2
-rw-r--r--src/mongo/db/exec/index_scan.cpp2
-rw-r--r--src/mongo/db/exec/multi_iterator.cpp2
-rw-r--r--src/mongo/db/exec/oplogstart.cpp4
-rw-r--r--src/mongo/db/exec/text_or.cpp6
-rw-r--r--src/mongo/db/exec/update.cpp8
-rw-r--r--src/mongo/db/ops/write_ops.h6
-rw-r--r--src/mongo/db/ops/write_ops_parsers.cpp45
-rw-r--r--src/mongo/db/query/plan_executor.cpp2
-rw-r--r--src/mongo/db/query/plan_yield_policy.cpp4
-rw-r--r--src/mongo/s/catalog/sharding_catalog_enable_sharding_test.cpp2
-rw-r--r--src/mongo/s/commands/cluster_write.cpp6
-rw-r--r--src/mongo/s/write_ops/batched_command_request.cpp39
-rw-r--r--src/mongo/s/write_ops/batched_command_request.h3
-rw-r--r--src/mongo/s/write_ops/batched_insert_request.cpp22
-rw-r--r--src/mongo/s/write_ops/batched_insert_request.h9
22 files changed, 77 insertions, 103 deletions
diff --git a/src/mongo/db/auth/user_cache_invalidator_job.cpp b/src/mongo/db/auth/user_cache_invalidator_job.cpp
index 5c9b7c30d8c..81602d77a14 100644
--- a/src/mongo/db/auth/user_cache_invalidator_job.cpp
+++ b/src/mongo/db/auth/user_cache_invalidator_job.cpp
@@ -94,7 +94,7 @@ public:
StatusWith<OID> getCurrentCacheGeneration(OperationContext* opCtx) {
try {
BSONObjBuilder result;
- const bool ok = grid.catalogClient()->runUserManagementReadCommand(
+ const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementReadCommand(
opCtx, "admin", BSON("_getUserCacheGeneration" << 1), &result);
if (!ok) {
return getStatusFromCommandResult(result.obj());
diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp
index 987f7c28513..c05dde68cea 100644
--- a/src/mongo/db/exec/collection_scan.cpp
+++ b/src/mongo/db/exec/collection_scan.cpp
@@ -147,7 +147,7 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) {
record = _cursor->next();
}
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// Leave us in a state to try again next time.
if (needToMakeCursor)
_cursor.reset();
diff --git a/src/mongo/db/exec/count_scan.cpp b/src/mongo/db/exec/count_scan.cpp
index 0693b310b02..8745ec48f41 100644
--- a/src/mongo/db/exec/count_scan.cpp
+++ b/src/mongo/db/exec/count_scan.cpp
@@ -114,7 +114,7 @@ PlanStage::StageState CountScan::doWork(WorkingSetID* out) {
} else {
entry = _cursor->next(kWantLoc);
}
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
if (needInit) {
// Release our cursor and try again next time.
_cursor.reset();
diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp
index 059f66a5cdb..6262279c054 100644
--- a/src/mongo/db/exec/delete.cpp
+++ b/src/mongo/db/exec/delete.cpp
@@ -177,7 +177,7 @@ PlanStage::StageState DeleteStage::doWork(WorkingSetID* out) {
try {
docStillMatches = write_stage_common::ensureStillMatches(
_collection, getOpCtx(), _ws, id, _params.canonicalQuery);
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// There was a problem trying to detect if the document still exists, so retry.
memberFreer.Dismiss();
return prepareToRetryWSM(id, out);
@@ -207,7 +207,7 @@ PlanStage::StageState DeleteStage::doWork(WorkingSetID* out) {
WorkingSetCommon::prepareForSnapshotChange(_ws);
try {
child()->saveState();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
std::terminate();
}
@@ -218,7 +218,7 @@ PlanStage::StageState DeleteStage::doWork(WorkingSetID* out) {
_collection->deleteDocument(
getOpCtx(), _params.stmtId, recordId, _params.opDebug, _params.fromMigrate);
wunit.commit();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
memberFreer.Dismiss(); // Keep this member around so we can retry deleting it.
return prepareToRetryWSM(id, out);
}
@@ -237,7 +237,7 @@ PlanStage::StageState DeleteStage::doWork(WorkingSetID* out) {
// outside of the WriteUnitOfWork.
try {
child()->restoreState();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// Note we don't need to retry anything in this case since the delete already was committed.
// However, we still need to return the deleted document (if it was requested).
if (_params.returnDeleted) {
diff --git a/src/mongo/db/exec/distinct_scan.cpp b/src/mongo/db/exec/distinct_scan.cpp
index 380bcf3474b..2b37e2ef38b 100644
--- a/src/mongo/db/exec/distinct_scan.cpp
+++ b/src/mongo/db/exec/distinct_scan.cpp
@@ -81,7 +81,7 @@ PlanStage::StageState DistinctScan::doWork(WorkingSetID* out) {
if (!_cursor)
_cursor = _iam->newCursor(getOpCtx(), _params.direction == 1);
kv = _cursor->seek(_seekPoint);
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
*out = WorkingSet::INVALID_ID;
return PlanStage::NEED_YIELD;
}
diff --git a/src/mongo/db/exec/fetch.cpp b/src/mongo/db/exec/fetch.cpp
index d42a86a8af0..f7d84305966 100644
--- a/src/mongo/db/exec/fetch.cpp
+++ b/src/mongo/db/exec/fetch.cpp
@@ -120,7 +120,7 @@ PlanStage::StageState FetchStage::doWork(WorkingSetID* out) {
_ws->free(id);
return NEED_TIME;
}
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// Ensure that the BSONObj underlying the WorkingSetMember is owned because it may
// be freed when we yield.
member->makeObjOwnedIfNeeded();
diff --git a/src/mongo/db/exec/idhack.cpp b/src/mongo/db/exec/idhack.cpp
index db24744f898..b0d88418572 100644
--- a/src/mongo/db/exec/idhack.cpp
+++ b/src/mongo/db/exec/idhack.cpp
@@ -160,7 +160,7 @@ PlanStage::StageState IDHackStage::doWork(WorkingSetID* out) {
}
return advance(id, member, out);
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// Restart at the beginning on retry.
_recordCursor.reset();
if (id != WorkingSet::INVALID_ID)
diff --git a/src/mongo/db/exec/index_scan.cpp b/src/mongo/db/exec/index_scan.cpp
index 50e4ff56962..793f1a1ae09 100644
--- a/src/mongo/db/exec/index_scan.cpp
+++ b/src/mongo/db/exec/index_scan.cpp
@@ -146,7 +146,7 @@ PlanStage::StageState IndexScan::doWork(WorkingSetID* out) {
case HIT_END:
return PlanStage::IS_EOF;
}
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
*out = WorkingSet::INVALID_ID;
return PlanStage::NEED_YIELD;
}
diff --git a/src/mongo/db/exec/multi_iterator.cpp b/src/mongo/db/exec/multi_iterator.cpp
index 24b8d375a67..69d83775543 100644
--- a/src/mongo/db/exec/multi_iterator.cpp
+++ b/src/mongo/db/exec/multi_iterator.cpp
@@ -78,7 +78,7 @@ PlanStage::StageState MultiIteratorStage::doWork(WorkingSetID* out) {
break;
_iterators.pop_back();
}
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// If _advance throws a WCE we shouldn't have moved.
invariant(!_iterators.empty());
*out = WorkingSet::INVALID_ID;
diff --git a/src/mongo/db/exec/oplogstart.cpp b/src/mongo/db/exec/oplogstart.cpp
index 8a8480ce136..49e81a0630f 100644
--- a/src/mongo/db/exec/oplogstart.cpp
+++ b/src/mongo/db/exec/oplogstart.cpp
@@ -80,7 +80,7 @@ PlanStage::StageState OplogStart::doWork(WorkingSetID* out) {
try {
// If this throws WCE, it leave us in a state were the next call to work will retry.
switchToExtentHopping();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
_subIterators.clear();
*out = WorkingSet::INVALID_ID;
return NEED_YIELD;
@@ -113,7 +113,7 @@ PlanStage::StageState OplogStart::workExtentHopping(WorkingSetID* out) {
return PlanStage::ADVANCED;
}
}
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
*out = WorkingSet::INVALID_ID;
return PlanStage::NEED_YIELD;
}
diff --git a/src/mongo/db/exec/text_or.cpp b/src/mongo/db/exec/text_or.cpp
index 5666feea046..bea23d39e34 100644
--- a/src/mongo/db/exec/text_or.cpp
+++ b/src/mongo/db/exec/text_or.cpp
@@ -165,7 +165,7 @@ PlanStage::StageState TextOrStage::initStage(WorkingSetID* out) {
_recordCursor = _index->getCollection()->getCursor(getOpCtx());
_internalState = State::kReadingTerms;
return PlanStage::NEED_TIME;
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
invariant(_internalState == State::kInit);
_recordCursor.reset();
return PlanStage::NEED_YIELD;
@@ -355,7 +355,7 @@ PlanStage::StageState TextOrStage::addTerm(WorkingSetID wsid, WorkingSetID* out)
wsid,
_recordCursor);
shouldKeep = _filter->matches(&tdoc);
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// Ensure that the BSONObj underlying the WorkingSetMember is owned because it may
// be freed when we yield.
wsm->makeObjOwnedIfNeeded();
@@ -380,7 +380,7 @@ PlanStage::StageState TextOrStage::addTerm(WorkingSetID wsid, WorkingSetID* out)
try {
shouldKeep = WorkingSetCommon::fetch(getOpCtx(), _ws, wsid, _recordCursor);
++_specificStats.fetches;
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
wsm->makeObjOwnedIfNeeded();
_idRetrying = wsid;
*out = WorkingSet::INVALID_ID;
diff --git a/src/mongo/db/exec/update.cpp b/src/mongo/db/exec/update.cpp
index 6b6af6f01ab..7e8c279c7d1 100644
--- a/src/mongo/db/exec/update.cpp
+++ b/src/mongo/db/exec/update.cpp
@@ -612,7 +612,7 @@ PlanStage::StageState UpdateStage::doWork(WorkingSetID* out) {
try {
docStillMatches = write_stage_common::ensureStillMatches(
_collection, getOpCtx(), _ws, id, _params.canonicalQuery);
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// There was a problem trying to detect if the document still exists, so retry.
memberFreer.Dismiss();
return prepareToRetryWSM(id, out);
@@ -635,7 +635,7 @@ PlanStage::StageState UpdateStage::doWork(WorkingSetID* out) {
WorkingSetCommon::prepareForSnapshotChange(_ws);
try {
child()->saveState();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
std::terminate();
}
@@ -649,7 +649,7 @@ PlanStage::StageState UpdateStage::doWork(WorkingSetID* out) {
try {
// Do the update, get us the new version of the doc.
newObj = transformAndUpdate(member->obj, recordId);
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
memberFreer.Dismiss(); // Keep this member around so we can retry updating it.
return prepareToRetryWSM(id, out);
}
@@ -676,7 +676,7 @@ PlanStage::StageState UpdateStage::doWork(WorkingSetID* out) {
// state outside of the WritUnitOfWork.
try {
child()->restoreState();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
// Note we don't need to retry updating anything in this case since the update
// already was committed. However, we still need to return the updated document
// (if it was requested).
diff --git a/src/mongo/db/ops/write_ops.h b/src/mongo/db/ops/write_ops.h
index 5463bb9a0e2..ec055786029 100644
--- a/src/mongo/db/ops/write_ops.h
+++ b/src/mongo/db/ops/write_ops.h
@@ -71,6 +71,12 @@ int32_t getStmtIdForWriteAt(const T& op, size_t writePos) {
return getStmtIdForWriteAt(op.getWriteCommandBase(), writePos);
}
+/**
+ * Must only be called if the insert is for the "system.indexes" namespace. Returns the actual
+ * namespace for which the index is being created.
+ */
+NamespaceString extractIndexedNamespace(const Insert& insertOp);
+
// TODO: Delete this getter once IDL supports defaults for object and array fields
template <class T>
const BSONObj& collationOf(const T& opEntry) {
diff --git a/src/mongo/db/ops/write_ops_parsers.cpp b/src/mongo/db/ops/write_ops_parsers.cpp
index b4e4b9157a7..10303f74a69 100644
--- a/src/mongo/db/ops/write_ops_parsers.cpp
+++ b/src/mongo/db/ops/write_ops_parsers.cpp
@@ -62,6 +62,30 @@ void checkOpCountForCommand(const T& op, size_t numOps) {
!stmtIds || stmtIds->size() == numOps);
}
+void validateInsertOp(const write_ops::Insert& insertOp) {
+ const auto& nss = insertOp.getNamespace();
+ const auto& docs = insertOp.getDocuments();
+
+ if (nss.isSystemDotIndexes()) {
+ // This is only for consistency with sharding.
+ uassert(ErrorCodes::InvalidLength,
+ "Insert commands to system.indexes are limited to a single insert",
+ insertOp.getDocuments().size() == 1);
+
+ const auto indexedNss(extractIndexedNamespace(insertOp));
+
+ uassert(ErrorCodes::InvalidNamespace,
+ str::stream() << indexedNss.ns() << " is not a valid namespace to index",
+ indexedNss.isValid());
+
+ uassert(ErrorCodes::IllegalOperation,
+ str::stream() << indexedNss.ns() << " is not in the target database " << nss.db(),
+ nss.db().compare(indexedNss.db()) == 0);
+ }
+
+ checkOpCountForCommand(insertOp, insertOp.getDocuments().size());
+}
+
} // namespace
namespace write_ops {
@@ -92,19 +116,21 @@ int32_t getStmtIdForWriteAt(const WriteCommandBase& writeCommandBase, size_t wri
return kFirstStmtId + writePos;
}
+NamespaceString extractIndexedNamespace(const Insert& insertOp) {
+ invariant(insertOp.getNamespace().isSystemDotIndexes());
+
+ const auto& documents = insertOp.getDocuments();
+ invariant(documents.size() == 1);
+
+ return NamespaceString(documents.at(0)["ns"].str());
+}
+
} // namespace write_ops
write_ops::Insert InsertOp::parse(const OpMsgRequest& request) {
auto insertOp = Insert::parse(IDLParserErrorContext("insert"), request);
- if (insertOp.getNamespace().isSystemDotIndexes()) {
- // This is only for consistency with sharding.
- uassert(ErrorCodes::InvalidLength,
- "Insert commands to system.indexes are limited to a single insert",
- insertOp.getDocuments().size() == 1);
- }
-
- checkOpCountForCommand(insertOp, insertOp.getDocuments().size());
+ validateInsertOp(insertOp);
return insertOp;
}
@@ -131,6 +157,7 @@ write_ops::Insert InsertOp::parseLegacy(const Message& msgRaw) {
return documents;
}());
+ validateInsertOp(op);
return op;
}
@@ -190,7 +217,7 @@ write_ops::Delete DeleteOp::parseLegacy(const Message& msgRaw) {
op.setWriteCommandBase(std::move(writeCommandBase));
}
- op.setDeletes([&]() {
+ op.setDeletes([&] {
std::vector<write_ops::DeleteOpEntry> deletes;
deletes.emplace_back();
diff --git a/src/mongo/db/query/plan_executor.cpp b/src/mongo/db/query/plan_executor.cpp
index 17aa8d42f02..c8a4ca98a3c 100644
--- a/src/mongo/db/query/plan_executor.cpp
+++ b/src/mongo/db/query/plan_executor.cpp
@@ -325,7 +325,7 @@ void PlanExecutor::saveState() {
bool PlanExecutor::restoreState() {
try {
return restoreStateWithoutRetrying();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
if (!_yieldPolicy->canAutoYield())
throw;
diff --git a/src/mongo/db/query/plan_yield_policy.cpp b/src/mongo/db/query/plan_yield_policy.cpp
index c5b54a90afb..483e24e9f7d 100644
--- a/src/mongo/db/query/plan_yield_policy.cpp
+++ b/src/mongo/db/query/plan_yield_policy.cpp
@@ -110,7 +110,7 @@ bool PlanYieldPolicy::yield(stdx::function<void()> beforeYieldingFn,
try {
_planYielding->saveState();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
invariant(!"WriteConflictException not allowed in saveState");
}
@@ -125,7 +125,7 @@ bool PlanYieldPolicy::yield(stdx::function<void()> beforeYieldingFn,
}
return _planYielding->restoreStateWithoutRetrying();
- } catch (const WriteConflictException& wce) {
+ } catch (const WriteConflictException&) {
CurOp::get(opCtx)->debug().writeConflicts++;
WriteConflictException::logAndBackoff(
attempt, "plan execution restoreState", _planYielding->nss().ns());
diff --git a/src/mongo/s/catalog/sharding_catalog_enable_sharding_test.cpp b/src/mongo/s/catalog/sharding_catalog_enable_sharding_test.cpp
index 7cccb916106..8007c729a0a 100644
--- a/src/mongo/s/catalog/sharding_catalog_enable_sharding_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_enable_sharding_test.cpp
@@ -51,8 +51,6 @@
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/config_server_test_fixture.h"
#include "mongo/s/write_ops/batched_command_response.h"
-#include "mongo/s/write_ops/batched_insert_request.h"
-#include "mongo/s/write_ops/batched_update_request.h"
#include "mongo/stdx/future.h"
#include "mongo/util/log.h"
#include "mongo/util/scopeguard.h"
diff --git a/src/mongo/s/commands/cluster_write.cpp b/src/mongo/s/commands/cluster_write.cpp
index 174d9773a0b..8f3ca8d22d7 100644
--- a/src/mongo/s/commands/cluster_write.cpp
+++ b/src/mongo/s/commands/cluster_write.cpp
@@ -210,12 +210,6 @@ void ClusterWriter::write(OperationContext* opCtx,
const NamespaceString& nss = request->getNS();
- std::string errMsg;
- if (request->isInsertIndexRequest() && !request->isValidIndexRequest(&errMsg)) {
- toBatchError(Status(ErrorCodes::InvalidOptions, errMsg), response);
- return;
- }
-
// Config writes and shard writes are done differently
if (nss.db() == NamespaceString::kConfigDb || nss.db() == NamespaceString::kAdminDb) {
Grid::get(opCtx)->catalogClient()->writeConfigServerDirect(opCtx, *request, response);
diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp
index d4a86b20c1d..65bdf090ce0 100644
--- a/src/mongo/s/write_ops/batched_command_request.cpp
+++ b/src/mongo/s/write_ops/batched_command_request.cpp
@@ -36,9 +36,12 @@
#include "mongo/stdx/memory.h"
namespace mongo {
+namespace {
const BSONField<BSONObj> writeConcern("writeConcern");
+} // namespace
+
BatchedCommandRequest::BatchedCommandRequest(BatchType batchType) : _batchType(batchType) {
switch (getBatchType()) {
case BatchedCommandRequest::BatchType_Insert:
@@ -83,41 +86,19 @@ BatchedDeleteRequest* BatchedCommandRequest::getDeleteRequest() const {
bool BatchedCommandRequest::isInsertIndexRequest() const {
if (_batchType != BatchedCommandRequest::BatchType_Insert)
return false;
+
return getNS().isSystemDotIndexes();
}
-bool BatchedCommandRequest::isValidIndexRequest(std::string* errMsg) const {
- std::string dummy;
- if (!errMsg)
- errMsg = &dummy;
- dassert(isInsertIndexRequest());
-
- if (sizeWriteOps() != 1) {
- *errMsg = "invalid batch request for index creation";
- return false;
- }
-
- const NamespaceString& targetNSS = getTargetingNSS();
- if (!targetNSS.isValid()) {
- *errMsg = targetNSS.ns() + " is not a valid namespace to index";
- return false;
- }
-
- const NamespaceString& reqNSS = getNS();
- if (reqNSS.db().compare(targetNSS.db()) != 0) {
- *errMsg =
- targetNSS.ns() + " namespace is not in the request database " + reqNSS.db().toString();
- return false;
+NamespaceString BatchedCommandRequest::getTargetingNSS() const {
+ if (!isInsertIndexRequest()) {
+ return getNS();
}
- return true;
-}
-
-const NamespaceString& BatchedCommandRequest::getTargetingNSS() const {
- if (!isInsertIndexRequest())
- return getNS();
+ const auto& documents = _insertReq->getDocuments();
+ invariant(documents.size() == 1);
- return _insertReq->getIndexTargetingNS();
+ return NamespaceString(documents.at(0)["ns"].str());
}
bool BatchedCommandRequest::isVerboseWC() const {
diff --git a/src/mongo/s/write_ops/batched_command_request.h b/src/mongo/s/write_ops/batched_command_request.h
index 6916d051a0e..dd7d96bcfce 100644
--- a/src/mongo/s/write_ops/batched_command_request.h
+++ b/src/mongo/s/write_ops/batched_command_request.h
@@ -90,9 +90,8 @@ public:
// Index creation is also an insert, but a weird one.
bool isInsertIndexRequest() const;
- bool isValidIndexRequest(std::string* errMsg) const;
- const NamespaceString& getTargetingNSS() const;
+ NamespaceString getTargetingNSS() const;
//
// individual field accessors
diff --git a/src/mongo/s/write_ops/batched_insert_request.cpp b/src/mongo/s/write_ops/batched_insert_request.cpp
index 23fb632d850..95eff792efb 100644
--- a/src/mongo/s/write_ops/batched_insert_request.cpp
+++ b/src/mongo/s/write_ops/batched_insert_request.cpp
@@ -34,14 +34,6 @@
#include "mongo/util/mongoutils/str.h"
namespace mongo {
-namespace {
-
-void extractIndexNSS(const BSONObj& indexDesc, NamespaceString* indexNSS) {
- *indexNSS = NamespaceString(indexDesc["ns"].str());
-}
-
-} // namespace
-
const BSONField<std::string> BatchedInsertRequest::collName("insert");
const BSONField<std::vector<BSONObj>> BatchedInsertRequest::documents("documents");
@@ -100,16 +92,11 @@ void BatchedInsertRequest::parseRequest(const OpMsgRequest& request) {
_documents.push_back(documentEntry.getOwned());
}
- if (_documents.size() >= 1) {
- extractIndexNSS(_documents.at(0), &_targetNSS);
- }
-
_isDocumentsSet = true;
}
void BatchedInsertRequest::clear() {
_ns = NamespaceString();
- _targetNSS = NamespaceString();
_isNSSet = false;
_documents.clear();
@@ -120,7 +107,6 @@ void BatchedInsertRequest::cloneTo(BatchedInsertRequest* other) const {
other->clear();
other->_ns = _ns;
- other->_targetNSS = _targetNSS;
other->_isNSSet = _isNSSet;
for (std::vector<BSONObj>::const_iterator it = _documents.begin(); it != _documents.end();
@@ -144,17 +130,9 @@ const NamespaceString& BatchedInsertRequest::getNS() const {
return _ns;
}
-const NamespaceString& BatchedInsertRequest::getIndexTargetingNS() const {
- return _targetNSS;
-}
-
void BatchedInsertRequest::addToDocuments(const BSONObj& documents) {
_documents.push_back(documents);
_isDocumentsSet = true;
-
- if (_documents.size() == 1) {
- extractIndexNSS(_documents.at(0), &_targetNSS);
- }
}
size_t BatchedInsertRequest::sizeDocuments() const {
diff --git a/src/mongo/s/write_ops/batched_insert_request.h b/src/mongo/s/write_ops/batched_insert_request.h
index a5a00de0e0c..ad215a5ad75 100644
--- a/src/mongo/s/write_ops/batched_insert_request.h
+++ b/src/mongo/s/write_ops/batched_insert_request.h
@@ -71,12 +71,6 @@ public:
void setNS(NamespaceString collName);
const NamespaceString& getNS() const;
- /**
- * Returns the ns for the index being created. Valid only if this is a index
- * insert request.
- */
- const NamespaceString& getIndexTargetingNS() const;
-
void addToDocuments(const BSONObj& documents);
std::size_t sizeDocuments() const;
const std::vector<BSONObj>& getDocuments() const;
@@ -93,9 +87,6 @@ private:
// (M) array of documents to be inserted
std::vector<BSONObj> _documents;
bool _isDocumentsSet;
-
- // (O) cached copied of target ns
- NamespaceString _targetNSS;
};
} // namespace mongo