summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_catalog_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/catalog/index_catalog_impl.cpp')
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp87
1 files changed, 36 insertions, 51 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 670622a17be..4e37bffe820 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -173,17 +173,16 @@ IndexCatalogEntry* IndexCatalogImpl::_setupInMemoryStructures(
}
if (!initFromDisk) {
- opCtx->recoveryUnit()->onRollback(
- [ this, opCtx, isReadyIndex, descriptor = descriptorPtr ] {
- // Need to preserve indexName as descriptor no longer exists after remove().
- const std::string indexName = descriptor->indexName();
- if (isReadyIndex) {
- _readyIndexes.remove(descriptor);
- } else {
- _buildingIndexes.remove(descriptor);
- }
- _collection->infoCache()->droppedIndex(opCtx, indexName);
- });
+ opCtx->recoveryUnit()->onRollback([this, opCtx, isReadyIndex, descriptor = descriptorPtr] {
+ // Need to preserve indexName as descriptor no longer exists after remove().
+ const std::string indexName = descriptor->indexName();
+ if (isReadyIndex) {
+ _readyIndexes.remove(descriptor);
+ } else {
+ _buildingIndexes.remove(descriptor);
+ }
+ _collection->infoCache()->droppedIndex(opCtx, indexName);
+ });
}
return save;
@@ -207,8 +206,7 @@ Status IndexCatalogImpl::checkUnfinished() const {
return Status(ErrorCodes::InternalError,
str::stream() << "IndexCatalog has left over indexes that must be cleared"
- << " ns: "
- << _collection->ns());
+ << " ns: " << _collection->ns());
}
std::unique_ptr<IndexCatalog::IndexIterator> IndexCatalogImpl::getIndexIterator(
@@ -244,8 +242,7 @@ string IndexCatalogImpl::_getAccessMethodName(const BSONObj& keyPattern) const {
// supports an index plugin unsupported by this version.
uassert(17197,
str::stream() << "Invalid index type '" << pluginName << "' "
- << "in index "
- << keyPattern,
+ << "in index " << keyPattern,
IndexNames::isKnownName(pluginName));
return pluginName;
@@ -432,10 +429,8 @@ StatusWith<BSONObj> IndexCatalogImpl::createIndexOnEmptyCollection(OperationCont
invariant(opCtx->lockState()->isCollectionLockedForMode(_collection->ns(), MODE_X));
invariant(_collection->numRecords(opCtx) == 0,
str::stream() << "Collection must be empty. Collection: " << _collection->ns()
- << " UUID: "
- << _collection->uuid()
- << " Count: "
- << _collection->numRecords(opCtx));
+ << " UUID: " << _collection->uuid()
+ << " Count: " << _collection->numRecords(opCtx));
_checkMagic();
Status status = checkUnfinished();
@@ -545,8 +540,7 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec)
if (!IndexDescriptor::isIndexVersionSupported(indexVersion)) {
return Status(ErrorCodes::CannotCreateIndex,
str::stream() << "this version of mongod cannot build new indexes "
- << "of version number "
- << static_cast<int>(indexVersion));
+ << "of version number " << static_cast<int>(indexVersion));
}
if (nss.isOplog())
@@ -563,9 +557,7 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec)
return Status(ErrorCodes::CannotCreateIndex,
str::stream() << "the \"ns\" field of the index spec '"
<< specNamespace.valueStringData()
- << "' does not match the collection name '"
- << nss
- << "'");
+ << "' does not match the collection name '" << nss << "'");
}
// logical name of the index
@@ -595,16 +587,15 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec)
if (indexNamespace.size() > NamespaceString::MaxNsLen)
return Status(ErrorCodes::CannotCreateIndex,
str::stream() << "namespace name generated from index name \""
- << indexNamespace
- << "\" is too long (127 byte max)");
+ << indexNamespace << "\" is too long (127 byte max)");
}
const BSONObj key = spec.getObjectField("key");
const Status keyStatus = index_key_validate::validateKeyPattern(key, indexVersion);
if (!keyStatus.isOK()) {
return Status(ErrorCodes::CannotCreateIndex,
- str::stream() << "bad index key pattern " << key << ": "
- << keyStatus.reason());
+ str::stream()
+ << "bad index key pattern " << key << ": " << keyStatus.reason());
}
const string pluginName = IndexNames::findPluginName(key);
@@ -633,18 +624,16 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec)
if (static_cast<IndexVersion>(vElt.numberInt()) < IndexVersion::kV2) {
return {ErrorCodes::CannotCreateIndex,
str::stream() << "Index version " << vElt.fieldNameStringData() << "="
- << vElt.numberInt()
- << " does not support the '"
- << collationElement.fieldNameStringData()
- << "' option"};
+ << vElt.numberInt() << " does not support the '"
+ << collationElement.fieldNameStringData() << "' option"};
}
if ((pluginName != IndexNames::BTREE) && (pluginName != IndexNames::GEO_2DSPHERE) &&
(pluginName != IndexNames::HASHED) && (pluginName != IndexNames::WILDCARD)) {
return Status(ErrorCodes::CannotCreateIndex,
- str::stream() << "Index type '" << pluginName
- << "' does not support collation: "
- << collator->getSpec().toBSON());
+ str::stream()
+ << "Index type '" << pluginName
+ << "' does not support collation: " << collator->getSpec().toBSON());
}
}
@@ -665,8 +654,8 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec)
if (spec.getField("expireAfterSeconds")) {
return Status(ErrorCodes::CannotCreateIndex,
- str::stream() << "Index type '" << pluginName
- << "' cannot be a TTL index");
+ str::stream()
+ << "Index type '" << pluginName << "' cannot be a TTL index");
}
}
@@ -776,21 +765,18 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx,
<< "An index with the same key pattern, but a different "
<< "collation already exists with the same name. Try again with "
<< "a unique name. "
- << "Existing index: "
- << desc->infoObj()
- << " Requested index: "
- << spec);
+ << "Existing index: " << desc->infoObj()
+ << " Requested index: " << spec);
}
if (SimpleBSONObjComparator::kInstance.evaluate(desc->keyPattern() != key) ||
SimpleBSONObjComparator::kInstance.evaluate(
desc->infoObj().getObjectField("collation") != collation)) {
return Status(ErrorCodes::IndexKeySpecsConflict,
- str::stream() << "Index must have unique name."
- << "The existing index: "
- << desc->infoObj()
- << " has the same name as the requested index: "
- << spec);
+ str::stream()
+ << "Index must have unique name."
+ << "The existing index: " << desc->infoObj()
+ << " has the same name as the requested index: " << spec);
}
IndexDescriptor temp(_collection, _getAccessMethodName(key), spec);
@@ -816,9 +802,9 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx,
IndexDescriptor temp(_collection, _getAccessMethodName(key), spec);
if (!desc->areIndexOptionsEquivalent(&temp))
return Status(ErrorCodes::IndexOptionsConflict,
- str::stream() << "Index: " << spec
- << " already exists with different options: "
- << desc->infoObj());
+ str::stream()
+ << "Index: " << spec
+ << " already exists with different options: " << desc->infoObj());
return Status(ErrorCodes::IndexOptionsConflict,
str::stream() << "Index with name: " << name
@@ -843,8 +829,7 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx,
return Status(ErrorCodes::CannotCreateIndex,
str::stream() << "only one text index per collection allowed, "
<< "found existing text index \""
- << textIndexes[0]->indexName()
- << "\"");
+ << textIndexes[0]->indexName() << "\"");
}
}
return Status::OK();