summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaria van Keulen <maria@mongodb.com>2017-09-19 16:45:33 -0400
committerMaria van Keulen <maria@mongodb.com>2017-09-19 16:45:33 -0400
commit469e035efb09fe7c59579e00796d4f6d429fb434 (patch)
treefe01aa78d0a49b9564446ae61c35a39b7125fd0c /src
parentb35c6fc183c26bc8a6d7cdfc8f5b970f90d60b56 (diff)
downloadmongo-469e035efb09fe7c59579e00796d4f6d429fb434.tar.gz
Revert "SERVER-30933 Change invariant to uassert for invalid uuid in queries"
This reverts commit 3eedd24bb8448e9a491a03d8eaa21999d4ea9405.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/query/query_request.cpp10
-rw-r--r--src/mongo/db/query/query_request.h3
-rw-r--r--src/mongo/db/query/query_request_test.cpp20
3 files changed, 4 insertions, 29 deletions
diff --git a/src/mongo/db/query/query_request.cpp b/src/mongo/db/query/query_request.cpp
index ec2da22eb65..cd09a591955 100644
--- a/src/mongo/db/query/query_request.cpp
+++ b/src/mongo/db/query/query_request.cpp
@@ -114,14 +114,10 @@ QueryRequest::QueryRequest(NamespaceString nss) : _nss(std::move(nss)) {}
QueryRequest::QueryRequest(CollectionUUID uuid) : _uuid(std::move(uuid)) {}
void QueryRequest::refreshNSS(OperationContext* opCtx) {
+ UUIDCatalog& catalog = UUIDCatalog::get(opCtx);
if (_uuid) {
- const UUIDCatalog& catalog = UUIDCatalog::get(opCtx);
- auto foundColl = catalog.lookupCollectionByUUID(_uuid.get());
- uassert(ErrorCodes::NamespaceNotFound,
- str::stream() << "UUID " << _uuid.get() << " specified in query request not found",
- foundColl);
- dassert(opCtx->lockState()->isDbLockedForMode(foundColl->ns().db(), MODE_IS));
- _nss = foundColl->ns();
+ invariant(catalog.lookupCollectionByUUID(_uuid.get()));
+ _nss = catalog.lookupNSSByUUID(_uuid.get());
}
invariant(!_nss.isEmpty());
}
diff --git a/src/mongo/db/query/query_request.h b/src/mongo/db/query/query_request.h
index a12491a14f4..dbe89f8d1d3 100644
--- a/src/mongo/db/query/query_request.h
+++ b/src/mongo/db/query/query_request.h
@@ -78,8 +78,7 @@ public:
/**
* If _uuid exists for this QueryRequest, use it to update the value of _nss via the
- * UUIDCatalog associated with opCtx. This should only be called when we hold a DBLock
- * on the database to which _uuid belongs, if the _uuid is present in the UUIDCatalog.
+ * UUIDCatalog associated with opCtx.
*/
void refreshNSS(OperationContext* opCtx);
diff --git a/src/mongo/db/query/query_request_test.cpp b/src/mongo/db/query/query_request_test.cpp
index 5fde88e0e22..a838cfd1882 100644
--- a/src/mongo/db/query/query_request_test.cpp
+++ b/src/mongo/db/query/query_request_test.cpp
@@ -32,14 +32,11 @@
#include <boost/optional.hpp>
#include <boost/optional/optional_io.hpp>
-#include "mongo/db/catalog/collection_mock.h"
-#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/json.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/pipeline/aggregation_request.h"
#include "mongo/db/query/query_request.h"
-#include "mongo/db/service_context_noop.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -1421,22 +1418,5 @@ TEST(QueryRequestTest, ParseFromLegacyQueryTooNegativeNToReturn) {
.getStatus());
}
-TEST(QueryRequestTest, ParseFromUUID) {
- ServiceContextNoop service;
- auto client = service.makeClient("test");
- auto opCtxNoop = client->makeOperationContext();
- auto opCtx = opCtxNoop.get();
- // Register a UUID/Collection pair in the UUIDCatalog.
- const CollectionUUID uuid = UUID::gen();
- const NamespaceString nss("test.testns");
- Collection coll(stdx::make_unique<CollectionMock>(nss));
- UUIDCatalog& catalog = UUIDCatalog::get(opCtx);
- catalog.onCreateCollection(opCtx, &coll, uuid);
- QueryRequest qr(uuid);
- // Ensure a call to refreshNSS succeeds.
- qr.refreshNSS(opCtx);
- ASSERT_EQ(nss, qr.nss());
-}
-
} // namespace mongo
} // namespace