summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2018-06-25 16:50:16 -0400
committerEric Milkie <milkie@10gen.com>2018-06-28 15:37:05 -0400
commit00e7bb4f5e46be31f371964186a31ac613a13a1c (patch)
tree34993a47264365c89a309c16e44793303b5add60 /src
parent343bd29619461dfd38f2e8d3fd355f7c625a971b (diff)
downloadmongo-00e7bb4f5e46be31f371964186a31ac613a13a1c.tar.gz
SERVER-35789 check for index catalog isready mismatch for multi-doc txns
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/index_catalog_entry_impl.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
index d12ad9e3b74..f44e5a0f31e 100644
--- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
@@ -162,6 +162,17 @@ const RecordId& IndexCatalogEntryImpl::head(OperationContext* opCtx) const {
}
bool IndexCatalogEntryImpl::isReady(OperationContext* opCtx) const {
+ auto session = OperationContextSession::get(opCtx);
+ // For multi-document transactions, we can open a snapshot prior to checking the
+ // 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.");
+ }
+
DEV invariant(_isReady == _catalogIsReady(opCtx));
return _isReady;
}