summaryrefslogtreecommitdiff
path: root/src/mongo/db/index/index_access_method.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/index/index_access_method.cpp')
-rw-r--r--src/mongo/db/index/index_access_method.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index f7bba190c2e..cac540aae8f 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -1116,6 +1116,17 @@ Status SortedDataIndexAccessMethod::_indexKeysOrWriteToSideTable(
*keysInsertedOut += inserted;
}
} else {
+ // Ensure that our snapshot is compatible with the index's minimum visibile snapshot.
+ const auto minVisibleTimestamp = _indexCatalogEntry->getMinimumVisibleSnapshot();
+ const auto readTimestamp =
+ opCtx->recoveryUnit()->getPointInTimeReadTimestamp(opCtx).value_or(
+ opCtx->recoveryUnit()->getCatalogConflictingTimestamp());
+ if (minVisibleTimestamp && !readTimestamp.isNull() &&
+ readTimestamp < *minVisibleTimestamp) {
+ throwWriteConflictException(
+ "Unable to read from a snapshot due to pending catalog changes.");
+ }
+
int64_t numInserted = 0;
status = insertKeysAndUpdateMultikeyPaths(
opCtx,
@@ -1178,6 +1189,15 @@ void SortedDataIndexAccessMethod::_unindexKeysOrWriteToSideTable(
options.dupsAllowed = options.dupsAllowed || !_indexCatalogEntry->isReady(opCtx) ||
(checkRecordId == CheckRecordId::On);
+ // Ensure that our snapshot is compatible with the index's minimum visibile snapshot.
+ const auto minVisibleTimestamp = _indexCatalogEntry->getMinimumVisibleSnapshot();
+ const auto readTimestamp = opCtx->recoveryUnit()->getPointInTimeReadTimestamp(opCtx).value_or(
+ opCtx->recoveryUnit()->getCatalogConflictingTimestamp());
+ if (minVisibleTimestamp && !readTimestamp.isNull() && readTimestamp < *minVisibleTimestamp) {
+ throwWriteConflictException(
+ "Unable to read from a snapshot due to pending catalog changes.");
+ }
+
int64_t removed = 0;
Status status = removeKeys(opCtx, keys, options, &removed);