diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 0f5d8a3677..5917f3d265 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -34,6 +34,7 @@ #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/index/index_descriptor.h" +#include "mongo/util/log.h" namespace mongo { using IndexIterator = IndexCatalog::IndexIterator; @@ -67,11 +68,19 @@ const IndexCatalogEntry* ReadyIndexesIterator::_advance() { ++_iterator; if (auto minSnapshot = entry->getMinimumVisibleSnapshot()) { - if (auto mySnapshot = _opCtx->recoveryUnit()->getPointInTimeReadTimestamp()) { - if (mySnapshot < minSnapshot) { - // This index isn't finished in my snapshot. - continue; - } + // if (auto mySnapshot = _opCtx->recoveryUnit()->getPointInTimeReadTimestamp()) { + // if (mySnapshot < minSnapshot) { + // // This index isn't finished in my snapshot. + // continue; + // } + // } + + Timestamp mySnapshot = + _opCtx->recoveryUnit()->getPointInTimeReadTimestamp().get_value_or( + _opCtx->recoveryUnit()->catalogConflictingTimestamp); + if (mySnapshot < minSnapshot) { + // This index isn't finished in my snapshot. + continue; } } diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h index a64ad387f1..f9b0ccdf18 100644 --- a/src/mongo/db/storage/recovery_unit.h +++ b/src/mongo/db/storage/recovery_unit.h @@ -567,6 +567,8 @@ public: _mustBeTimestamped = true; } + Timestamp catalogConflictingTimestamp = Timestamp::max(); + protected: RecoveryUnit() {} diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp index 1e2327cdd3..07adcc2571 100644 --- a/src/mongo/db/transaction_participant.cpp +++ b/src/mongo/db/transaction_participant.cpp @@ -596,6 +596,8 @@ void TransactionParticipant::Participant::_setReadSnapshot(OperationContext* opC // 'holes' from writes earlier than the last applied write which have not yet completed. // Using 'kNoTimestamp' ensures that transactions with mode 'local' are always able to read // writes from earlier transactions with mode 'local' on the same connection. + opCtx->recoveryUnit()->catalogConflictingTimestamp = + repl::StorageInterface::get(opCtx)->getAllDurableTimestamp(opCtx->getServiceContext()); opCtx->recoveryUnit()->setTimestampReadSource(RecoveryUnit::ReadSource::kNoTimestamp); }