summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-05-22 11:57:52 -0400
committerBenety Goh <benety@mongodb.com>2017-05-23 18:30:12 -0400
commita4a7575ab62fc686d82e6e5706467d55cdfd6b08 (patch)
treef2a648d35a45c9b6bcb49bd2e4f9ce6fa3d14cab /src
parentf56ae945275aa9360d2d6eae192b64d558ede20b (diff)
downloadmongo-a4a7575ab62fc686d82e6e5706467d55cdfd6b08.tar.gz
SERVER-29274 IndexCatalog::dropAllIndexes() returns void.
This function throws an exception on error or fasserts.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/collection_compact.cpp5
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp6
-rw-r--r--src/mongo/db/catalog/database_impl.cpp10
-rw-r--r--src/mongo/db/catalog/drop_indexes.cpp5
-rw-r--r--src/mongo/db/catalog/index_catalog.h14
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp8
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.h6
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp6
8 files changed, 20 insertions, 40 deletions
diff --git a/src/mongo/db/catalog/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp
index c16153a2e24..a4e1f40c603 100644
--- a/src/mongo/db/catalog/collection_compact.cpp
+++ b/src/mongo/db/catalog/collection_compact.cpp
@@ -175,10 +175,7 @@ StatusWith<CompactStats> CollectionImpl::compact(OperationContext* opCtx,
// which is important and wanted here
WriteUnitOfWork wunit(opCtx);
log() << "compact dropping indexes";
- Status status = _indexCatalog.dropAllIndexes(opCtx, true);
- if (!status.isOK()) {
- return StatusWith<CompactStats>(status);
- }
+ _indexCatalog.dropAllIndexes(opCtx, true);
wunit.commit();
}
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index 05230692281..3b86b48d542 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -854,13 +854,11 @@ Status CollectionImpl::truncate(OperationContext* opCtx) {
}
// 2) drop indexes
- Status status = _indexCatalog.dropAllIndexes(opCtx, true);
- if (!status.isOK())
- return status;
+ _indexCatalog.dropAllIndexes(opCtx, true);
_cursorManager.invalidateAll(opCtx, false, "collection truncated");
// 3) truncate record store
- status = _recordStore->truncate(opCtx);
+ auto status = _recordStore->truncate(opCtx);
if (!status.isOK())
return status;
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index 518508663e5..cb96f05e0de 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -424,13 +424,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx,
audit::logDropCollection(&cc(), fullns.toString());
collection->getCursorManager()->invalidateAll(opCtx, true, "collection dropped");
- Status s = collection->getIndexCatalog()->dropAllIndexes(opCtx, true);
-
- if (!s.isOK()) {
- warning() << "could not drop collection, trying to drop indexes" << fullns << " because of "
- << redact(s.toString());
- return s;
- }
+ collection->getIndexCatalog()->dropAllIndexes(opCtx, true);
verify(collection->getCatalogEntry()->getTotalIndexCount(opCtx) == 0);
LOG(1) << "\t dropIndexes done";
@@ -442,7 +436,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx,
auto uuid = collection->uuid();
_clearCollectionCache(opCtx, fullns.toString(), "collection dropped");
- s = _dbEntry->dropCollection(opCtx, fullns.toString());
+ auto s = _dbEntry->dropCollection(opCtx, fullns.toString());
if (!s.isOK())
return s;
diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp
index 3ef36e6dbd7..2081f58d6ae 100644
--- a/src/mongo/db/catalog/drop_indexes.cpp
+++ b/src/mongo/db/catalog/drop_indexes.cpp
@@ -62,10 +62,7 @@ Status wrappedRun(OperationContext* opCtx,
if (indexToDelete == "*") {
std::map<std::string, BSONObj> droppedIndexes;
- Status s = indexCatalog->dropAllIndexes(opCtx, false, &droppedIndexes);
- if (!s.isOK()) {
- return s;
- }
+ indexCatalog->dropAllIndexes(opCtx, false, &droppedIndexes);
// We log one op for every dropped index so that we can roll them back if necessary.
for (auto const& idx : droppedIndexes) {
diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h
index 86e98e061dd..f72c485d03d 100644
--- a/src/mongo/db/catalog/index_catalog.h
+++ b/src/mongo/db/catalog/index_catalog.h
@@ -208,9 +208,9 @@ public:
virtual StatusWith<BSONObj> prepareSpecForCreate(OperationContext* opCtx,
const BSONObj& original) const = 0;
- virtual Status dropAllIndexes(OperationContext* opCtx,
- bool includingIdIndex,
- std::map<std::string, BSONObj>* droppedIndexes) = 0;
+ virtual void dropAllIndexes(OperationContext* opCtx,
+ bool includingIdIndex,
+ std::map<std::string, BSONObj>* droppedIndexes) = 0;
virtual Status dropIndex(OperationContext* opCtx, IndexDescriptor* desc) = 0;
@@ -455,10 +455,10 @@ public:
* 'includingIdIndex' parameter value. If the 'droppedIndexes' parameter is not null,
* it is filled with the names and index info of the dropped indexes.
*/
- inline Status dropAllIndexes(OperationContext* const opCtx,
- const bool includingIdIndex,
- std::map<std::string, BSONObj>* const droppedIndexes = nullptr) {
- return this->_impl().dropAllIndexes(opCtx, includingIdIndex, droppedIndexes);
+ inline void dropAllIndexes(OperationContext* const opCtx,
+ const bool includingIdIndex,
+ std::map<std::string, BSONObj>* const droppedIndexes = nullptr) {
+ this->_impl().dropAllIndexes(opCtx, includingIdIndex, droppedIndexes);
}
inline Status dropIndex(OperationContext* const opCtx, IndexDescriptor* const desc) {
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 9f88b72bd49..29183e04737 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -848,9 +848,9 @@ BSONObj IndexCatalogImpl::getDefaultIdIndexSpec(
return b.obj();
}
-Status IndexCatalogImpl::dropAllIndexes(OperationContext* opCtx,
- bool includingIdIndex,
- std::map<std::string, BSONObj>* droppedIndexes) {
+void IndexCatalogImpl::dropAllIndexes(OperationContext* opCtx,
+ bool includingIdIndex,
+ std::map<std::string, BSONObj>* droppedIndexes) {
invariant(opCtx->lockState()->isCollectionLockedForMode(_collection->ns().toString(), MODE_X));
BackgroundOperation::assertNoBgOpInProgForNs(_collection->ns().ns());
@@ -920,8 +920,6 @@ Status IndexCatalogImpl::dropAllIndexes(OperationContext* opCtx,
fassert(17328, numIndexesInCollectionCatalogEntry == 0);
fassert(17337, _entries.size() == 0);
}
-
- return Status::OK();
}
Status IndexCatalogImpl::dropIndex(OperationContext* opCtx, IndexDescriptor* desc) {
diff --git a/src/mongo/db/catalog/index_catalog_impl.h b/src/mongo/db/catalog/index_catalog_impl.h
index 889c14039e9..09abe7a311f 100644
--- a/src/mongo/db/catalog/index_catalog_impl.h
+++ b/src/mongo/db/catalog/index_catalog_impl.h
@@ -229,9 +229,9 @@ public:
* 'includingIdIndex' parameter value. If the 'droppedIndexes' parameter is not null,
* it is filled with the names and index info of the dropped indexes.
*/
- Status dropAllIndexes(OperationContext* opCtx,
- bool includingIdIndex,
- std::map<std::string, BSONObj>* droppedIndexes = nullptr) override;
+ void dropAllIndexes(OperationContext* opCtx,
+ bool includingIdIndex,
+ std::map<std::string, BSONObj>* droppedIndexes = nullptr) override;
Status dropIndex(OperationContext* opCtx, IndexDescriptor* desc) override;
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index b8c6e5442cb..e970705d9f1 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -190,11 +190,7 @@ public:
{
WriteUnitOfWork wunit(opCtx);
- Status s = collection->getIndexCatalog()->dropAllIndexes(opCtx, true);
- if (!s.isOK()) {
- errmsg = "dropIndexes failed";
- return appendCommandStatus(result, s);
- }
+ collection->getIndexCatalog()->dropAllIndexes(opCtx, true);
wunit.commit();
}