diff options
| author | Benety Goh <benety@mongodb.com> | 2017-07-11 13:09:35 -0400 |
|---|---|---|
| committer | Benety Goh <benety@mongodb.com> | 2017-07-12 18:57:47 -0400 |
| commit | 9bd5e1f1de06b7d6f97030036a2d03424399b5d0 (patch) | |
| tree | 3d77ba78b1e489a0b4beaace2378ada57ec496ec /src | |
| parent | 32ce928cb3275bb3de7c1e1ccc99d3c1e57cdc72 (diff) | |
SERVER-29373 relax index name constraint when doing two phase collection drops under non-mmapv1 storage enginesr3.5.10
Diffstat (limited to 'src')
| -rw-r--r-- | src/mongo/db/catalog/database_impl.cpp | 23 | ||||
| -rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 17 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index e96bd7325d6..1141dab3c72 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -511,16 +511,21 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx, } } - // Check if drop-pending namespace is too long for the index names in the collection. auto dpns = fullns.makeDropPendingNamespace(dropOpTime); - auto status = - dpns.checkLengthForRename(collection->getIndexCatalog()->getLongestIndexNameLength(opCtx)); - if (!status.isOK()) { - log() << "dropCollection: " << fullns - << " - cannot proceed with collection rename for pending-drop: " << status - << ". Dropping collection immediately."; - fassertStatusOK(40463, _finishDropCollection(opCtx, fullns, collection)); - return Status::OK(); + + // MMAPv1 requires that index namespaces are subject to the same length constraints as indexes + // in collections that are not in a drop-pending state. Therefore, we check if the drop-pending + // namespace is too long for the index names in the collection. + if (opCtx->getServiceContext()->getGlobalStorageEngine()->isMmapV1()) { + auto status = dpns.checkLengthForRename( + collection->getIndexCatalog()->getLongestIndexNameLength(opCtx)); + if (!status.isOK()) { + log() << "dropCollection: " << fullns + << " - cannot proceed with collection rename for pending-drop: " << status + << ". Dropping collection immediately."; + fassertStatusOK(40463, _finishDropCollection(opCtx, fullns, collection)); + return Status::OK(); + } } // Rename collection using drop-pending namespace generated from drop optime. diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index e9cfd3a4f0c..40f2ecb1c0d 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -590,12 +590,17 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec) if (name.empty()) return Status(ErrorCodes::CannotCreateIndex, "index name cannot be empty"); - const std::string indexNamespace = IndexDescriptor::makeIndexNamespace(nss.ns(), name); - if (indexNamespace.length() > NamespaceString::MaxNsLen) - return Status(ErrorCodes::CannotCreateIndex, - str::stream() << "namespace name generated from index name \"" - << indexNamespace - << "\" is too long (127 byte max)"); + // Drop pending collections are internal to the server and will not be exported to another + // storage engine. The indexes contained in these collections are not subject to the same + // namespace length constraints as the ones in created by users. + if (!nss.isDropPendingNamespace()) { + auto indexNamespace = IndexDescriptor::makeIndexNamespace(nss.ns(), name); + if (indexNamespace.length() > NamespaceString::MaxNsLen) + return Status(ErrorCodes::CannotCreateIndex, + str::stream() << "namespace name generated from index name \"" + << indexNamespace + << "\" is too long (127 byte max)"); + } const BSONObj key = spec.getObjectField("key"); const Status keyStatus = index_key_validate::validateKeyPattern(key, indexVersion); |
