summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/drop_collection.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-08-14 10:23:04 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-02 23:53:39 +0000
commitbf5914a20b596ba3bde772b42e579e028f733bac (patch)
tree2b26469571786d9adb5e95c47990c2416bfab9c4 /src/mongo/db/catalog/drop_collection.cpp
parent6b3e341703b781bb1ff7b1263406a0f1d28dd77c (diff)
downloadmongo-bf5914a20b596ba3bde772b42e579e028f733bac.tar.gz
SERVER-50317 Const correct uses of Collection
Most of the code should only need a const Collection now. AutoGetCollection returns a const Collection by default. There is a placeholder getWritableCollection() interface that will handle the necessary steps we need for lock free reads in the future. Added some operators to AutoGetCollection so it behaves more like a smart pointer.
Diffstat (limited to 'src/mongo/db/catalog/drop_collection.cpp')
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index 69a7eaadc58..c3470d56941 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -53,7 +53,7 @@ namespace mongo {
MONGO_FAIL_POINT_DEFINE(hangDropCollectionBeforeLockAcquisition);
MONGO_FAIL_POINT_DEFINE(hangDuringDropCollection);
-Status _checkNssAndReplState(OperationContext* opCtx, Collection* coll) {
+Status _checkNssAndReplState(OperationContext* opCtx, const Collection* coll) {
if (!coll) {
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
@@ -134,7 +134,7 @@ Status _abortIndexBuildsAndDropCollection(OperationContext* opCtx,
// which may have changed when we released the collection lock temporarily.
opCtx->recoveryUnit()->abandonSnapshot();
- Collection* coll =
+ const Collection* coll =
CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, startingNss);
Status status = _checkNssAndReplState(opCtx, coll);
if (!status.isOK()) {
@@ -185,7 +185,8 @@ Status _abortIndexBuildsAndDropCollection(OperationContext* opCtx,
// disk state, which may have changed when we released the collection lock temporarily.
opCtx->recoveryUnit()->abandonSnapshot();
- coll = CollectionCatalog::get(opCtx).lookupCollectionByUUID(opCtx, collectionUUID);
+ const Collection* coll =
+ CollectionCatalog::get(opCtx).lookupCollectionByUUID(opCtx, collectionUUID);
status = _checkNssAndReplState(opCtx, coll);
if (!status.isOK()) {
return status;
@@ -236,7 +237,7 @@ Status _dropCollection(OperationContext* opCtx,
DropCollectionSystemCollectionMode systemCollectionMode,
BSONObjBuilder& result) {
Lock::CollectionLock collLock(opCtx, collectionName, MODE_X);
- Collection* coll =
+ const Collection* coll =
CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, collectionName);
Status status = _checkNssAndReplState(opCtx, coll);
if (!status.isOK()) {
@@ -299,7 +300,7 @@ Status dropCollection(OperationContext* opCtx,
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
- Collection* coll = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(
+ const Collection* coll = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(
opCtx, collectionName);
if (!coll) {
@@ -336,7 +337,7 @@ Status dropCollectionForApplyOps(OperationContext* opCtx,
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
- Collection* coll =
+ const Collection* coll =
CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, collectionName);
BSONObjBuilder unusedBuilder;