Skip to content

Commit cd96f9b

Browse files
alextaskovevergreen
authored andcommitted
SERVER-42751 Take CSRLock when observing transaction commit for migration
1 parent 1241b15 commit cd96f9b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,15 @@ void LogTransactionOperationsForShardingHandler::commit(boost::optional<Timestam
163163
const auto& nss = stmt.getNss();
164164

165165
auto csr = CollectionShardingRuntime::get_UNSAFE(_svcCtx, nss);
166-
auto msm = MigrationSourceManager::get_UNSAFE(csr);
166+
167+
auto opCtx = cc().getOperationContext();
168+
auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr);
169+
170+
auto msm = MigrationSourceManager::get(csr, csrLock);
167171
if (!msm) {
168172
continue;
169173
}
174+
170175
auto cloner = dynamic_cast<MigrationChunkClonerSourceLegacy*>(msm->getCloner().get());
171176

172177
auto opType = stmt.getOpType();

0 commit comments

Comments
 (0)