diff options
author | Dewal Gupta <dewal.gupta@10gen.com> | 2018-07-23 17:46:33 -0400 |
---|---|---|
committer | Dewal Gupta <dewal.gupta@10gen.com> | 2018-07-27 10:43:28 -0400 |
commit | dfdffb7e4588d41c99e625ade8e9aa638b0c3fd4 (patch) | |
tree | ed687090014ef5c60e3bbc88ce0483e3d89a14ef /src/mongo/db/catalog/index_catalog_entry_impl.cpp | |
parent | f833e9dc5eab387bde7d507bcfbfe3c036d5447a (diff) | |
download | mongo-dfdffb7e4588d41c99e625ade8e9aa638b0c3fd4.tar.gz |
SERVER-36005 Prevent unsafe IndexCatalogEntryImpl::_catalogIsReady call
Diffstat (limited to 'src/mongo/db/catalog/index_catalog_entry_impl.cpp')
-rw-r--r-- | src/mongo/db/catalog/index_catalog_entry_impl.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp index f44e5a0f31e..09859e35b4c 100644 --- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp @@ -167,10 +167,12 @@ bool IndexCatalogEntryImpl::isReady(OperationContext* opCtx) const { // minimumSnapshotVersion on a collection. This means we are unprotected from reading // out-of-sync index catalog entries. To fix this, we uassert if we detect that the // in-memory catalog is out-of-sync with the on-disk catalog. - if (session && session->inMultiDocumentTransaction() && _catalogIsReady(opCtx) != _isReady) { - uasserted(ErrorCodes::SnapshotUnavailable, - str::stream() << "Unable to read from a snapshot due to pending collection" - " catalog changes; please retry the operation."); + if (session && session->inMultiDocumentTransaction()) { + if (!_catalogIsPresent(opCtx) || _catalogIsReady(opCtx) != _isReady) { + uasserted(ErrorCodes::SnapshotUnavailable, + str::stream() << "Unable to read from a snapshot due to pending collection" + " catalog changes; please retry the operation."); + } } DEV invariant(_isReady == _catalogIsReady(opCtx)); @@ -360,6 +362,10 @@ RecordId IndexCatalogEntryImpl::_catalogHead(OperationContext* opCtx) const { return _collection->getIndexHead(opCtx, _descriptor->indexName()); } +bool IndexCatalogEntryImpl::_catalogIsPresent(OperationContext* opCtx) const { + return _collection->isIndexPresent(opCtx, _descriptor->indexName()); +} + bool IndexCatalogEntryImpl::_catalogIsMultikey(OperationContext* opCtx, MultikeyPaths* multikeyPaths) const { return _collection->isIndexMultikey(opCtx, _descriptor->indexName(), multikeyPaths); |