summaryrefslogtreecommitdiff
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-05-01 12:38:14 -0400
commitad1be35c31ede230c13de3c4acfeae1c594ac280 (patch)
tree31137d92d08a46640d0eeb4d9c61627d44c4dff8
parentb67e3c53ea2be50c8ecdc27e1499604ee98d445c (diff)
downloadmongo-ad1be35c31ede230c13de3c4acfeae1c594ac280.tar.gz
SERVER-40786 Improve error message in IndexCatalog::dropAllIndexes()
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp68
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.h5
2 files changed, 67 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 5dd4bcdfe26..72b69d9c344 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -308,6 +308,66 @@ Status IndexCatalogImpl::_upgradeDatabaseMinorVersionIfNeeded(OperationContext*
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().toString(), MODE_X));
+
+ error() << "Internal Index Catalog state: "
+ << " numIndexesTotal(): " << numIndexesTotal(opCtx)
+ << " numSystemIndexesEntries: " << numIndexesInCollectionCatalogEntry
+ << " _entries.size(): " << _entries.size()
+ << " indexNamesToDrop: " << indexNamesToDrop.size() << " haveIdIndex: " << haveIdIndex;
+
+ // Report the ready indexes.
+ error() << "Ready indexes:";
+ for (const auto& entry : _entries) {
+ if (!entry->isReady(opCtx)) {
+ continue;
+ }
+ 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 : _entries) {
+ if (entry->isReady(opCtx)) {
+ continue;
+ }
+ 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 {
Status status = _isSpecOk(opCtx, original);
@@ -960,12 +1020,8 @@ void IndexCatalogImpl::dropAllIndexes(OperationContext* opCtx,
fassert(17336, _entries.size() == 1);
} else {
if (numIndexesTotal(opCtx) || numIndexesInCollectionCatalogEntry || _entries.size()) {
- error() << "About to fassert - "
- << " numIndexesTotal(): " << numIndexesTotal(opCtx)
- << " numSystemIndexesEntries: " << numIndexesInCollectionCatalogEntry
- << " _entries.size(): " << _entries.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 d0b59ec9652..906f66d731b 100644
--- a/src/mongo/db/catalog/index_catalog_impl.h
+++ b/src/mongo/db/catalog/index_catalog_impl.h
@@ -453,6 +453,11 @@ private:
}
+ void _logInternalState(OperationContext* opCtx,
+ long long numIndexesInCollectionCatalogEntry,
+ const std::vector<std::string>& indexNamesToDrop,
+ bool haveIdIndex);
+
int _magic;
Collection* const _collection;
const int _maxNumIndexesAllowed;