summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/repl/tenant_oplog_applier.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/mongo/db/repl/tenant_oplog_applier.cpp b/src/mongo/db/repl/tenant_oplog_applier.cpp
index 44db0b4f06b..a5330eb1aa2 100644
--- a/src/mongo/db/repl/tenant_oplog_applier.cpp
+++ b/src/mongo/db/repl/tenant_oplog_applier.cpp
@@ -921,24 +921,27 @@ Status TenantOplogApplier::_applyOplogEntryOrGroupedInserts(
if (op.getCommandType() == OplogEntry::CommandType::kCreateIndexes) {
auto uuid = op.getUuid();
uassert(5652700, "Missing UUID from createIndex oplog entry", uuid);
- AutoGetCollectionForRead autoColl(opCtx, {op.getNss().db().toString(), *uuid});
- if (!autoColl.getCollection()) {
+ try {
+ AutoGetCollectionForRead autoColl(opCtx, {op.getNss().db().toString(), *uuid});
+ uassert(ErrorCodes::NamespaceNotFound, "Collection does not exist", autoColl);
+ // During tenant migration oplog application, we only need to apply createIndex on empty
+ // collections. Otherwise, the index is guaranteed to be dropped after. This is because
+ // we block index builds on the donor for the duration of the tenant migration.
+ if (!Helpers::findOne(
+ opCtx, autoColl.getCollection(), BSONObj(), false /* requireIndex */)
+ .isNull()) {
+ LOGV2_DEBUG(5652701,
+ 2,
+ "Tenant migration ignoring createIndex for non-empty collection",
+ "op"_attr = redact(op.toBSONForLogging()),
+ "tenant"_attr = _tenantId,
+ "migrationUuid"_attr = _migrationUuid);
+ return Status::OK();
+ }
+ } catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
// If the collection doesn't exist, it is safe to ignore.
return Status::OK();
}
- // During tenant migration oplog application, we only need to apply createIndex on empty
- // collections. Otherwise, the index is guaranteed to be dropped after. This is because we
- // block index builds on the donor for the duration of the tenant migration.
- if (!Helpers::findOne(opCtx, autoColl.getCollection(), BSONObj(), false /* requireIndex */)
- .isNull()) {
- LOGV2_DEBUG(5652701,
- 2,
- "Tenant migration ignoring createIndex for non-empty collection",
- "op"_attr = redact(op.toBSONForLogging()),
- "tenant"_attr = _tenantId,
- "migrationUuid"_attr = _migrationUuid);
- return Status::OK();
- }
}
// We don't count tenant application in the ops applied stats.
auto incrementOpsAppliedStats = [] {};