summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-04-29 09:03:20 -0400
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-04-30 15:50:10 -0400
commitcad0509bf1a5ad7b922de7fd80121534504df081 (patch)
tree60ca938037a735a103c186e5def46d58a524f074 /src/mongo/db/catalog
parentf7a4c4a9632f75996ed607ffc77e2a3cab15ea88 (diff)
downloadmongo-cad0509bf1a5ad7b922de7fd80121534504df081.tar.gz
SERVER-40786 Improve error message in IndexCatalog::dropAllIndexes()
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp63
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.h5
2 files changed, 62 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 3c26997d12e..24287950d95 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -323,6 +323,61 @@ Status IndexCatalogImpl::_isNonIDIndexAndNotAllowedToBuild(OperationContext* opC
return Status::OK();
}
+void IndexCatalogImpl::_logInternalState(OperationContext* opCtx,
+ long long numIndexesInCollectionCatalogEntry,
+ const std::vector<std::string>& indexNamesToDrop,
+ bool haveIdIndex) {
+ invariant(opCtx->lockState()->isCollectionLockedForMode(_collection->ns(), MODE_X));
+
+ error() << "Internal Index Catalog state: "
+ << " numIndexesTotal(): " << numIndexesTotal(opCtx)
+ << " numSystemIndexesEntries: " << numIndexesInCollectionCatalogEntry
+ << " _readyIndexes.size(): " << _readyIndexes.size()
+ << " _buildingIndexes.size(): " << _buildingIndexes.size()
+ << " indexNamesToDrop: " << indexNamesToDrop.size() << " haveIdIndex: " << haveIdIndex;
+
+ // Report the ready indexes.
+ error() << "Ready indexes:";
+ for (const auto& entry : _readyIndexes) {
+ const IndexDescriptor* desc = entry->descriptor();
+ error() << "Index '" << desc->indexName()
+ << "' with specification: " << redact(desc->infoObj());
+ }
+
+ // Report the in-progress indexes.
+ error() << "In-progress indexes:";
+ for (const auto& entry : _buildingIndexes) {
+ const IndexDescriptor* desc = entry->descriptor();
+ error() << "Index '" << desc->indexName()
+ << "' with specification: " << redact(desc->infoObj());
+ }
+
+ error() << "Internal Collection Catalog Entry state:";
+ std::vector<std::string> allIndexes;
+ std::vector<std::string> readyIndexes;
+
+ _collection->getCatalogEntry()->getAllIndexes(opCtx, &allIndexes);
+ _collection->getCatalogEntry()->getReadyIndexes(opCtx, &readyIndexes);
+
+ error() << "All indexes:";
+ for (const auto& index : allIndexes) {
+ error() << "Index '" << index << "' with specification: "
+ << redact(_collection->getCatalogEntry()->getIndexSpec(opCtx, index));
+ }
+
+ error() << "Ready indexes:";
+ for (const auto& index : readyIndexes) {
+ error() << "Index '" << index << "' with specification: "
+ << redact(_collection->getCatalogEntry()->getIndexSpec(opCtx, index));
+ }
+
+ error() << "Index names to drop:";
+ for (const auto& indexNameToDrop : indexNamesToDrop) {
+ error() << "Index '" << indexNameToDrop << "' with specification: "
+ << redact(_collection->getCatalogEntry()->getIndexSpec(opCtx, indexNameToDrop));
+ }
+}
+
StatusWith<BSONObj> IndexCatalogImpl::prepareSpecForCreate(OperationContext* opCtx,
const BSONObj& original) const {
auto swValidatedAndFixed = _validateAndFixIndexSpec(opCtx, original);
@@ -876,12 +931,8 @@ void IndexCatalogImpl::dropAllIndexes(OperationContext* opCtx,
fassert(17336, _readyIndexes.size() == 1);
} else {
if (numIndexesTotal(opCtx) || numIndexesInCollectionCatalogEntry || _readyIndexes.size()) {
- error() << "About to fassert - "
- << " numIndexesTotal(): " << numIndexesTotal(opCtx)
- << " numSystemIndexesEntries: " << numIndexesInCollectionCatalogEntry
- << " _readyIndexes.size(): " << _readyIndexes.size()
- << " indexNamesToDrop: " << indexNamesToDrop.size()
- << " haveIdIndex: " << haveIdIndex;
+ _logInternalState(
+ opCtx, numIndexesInCollectionCatalogEntry, indexNamesToDrop, haveIdIndex);
}
fassert(17327, numIndexesTotal(opCtx) == 0);
fassert(17328, numIndexesInCollectionCatalogEntry == 0);
diff --git a/src/mongo/db/catalog/index_catalog_impl.h b/src/mongo/db/catalog/index_catalog_impl.h
index 1bfde7395ac..28a1233c58d 100644
--- a/src/mongo/db/catalog/index_catalog_impl.h
+++ b/src/mongo/db/catalog/index_catalog_impl.h
@@ -457,6 +457,11 @@ private:
*/
Status _isNonIDIndexAndNotAllowedToBuild(OperationContext* opCtx, const BSONObj& spec) const;
+ void _logInternalState(OperationContext* opCtx,
+ long long numIndexesInCollectionCatalogEntry,
+ const std::vector<std::string>& indexNamesToDrop,
+ bool haveIdIndex);
+
int _magic;
Collection* const _collection;
const int _maxNumIndexesAllowed;