void OpObserverShardingImpl::shardObserveInsertOp(OperationContext* opCtx, const NamespaceString nss, const BSONObj& insertedDoc, const repl::OpTime& opTime, const bool fromMigrate, const bool inMultiDocumentTransaction) { auto* const csr = (nss == NamespaceString::kSessionTransactionsTableNamespace || fromMigrate) ? nullptr : CollectionShardingRuntime::get(opCtx, nss); if (!csr) { return; } csr->checkShardVersionOrThrow(opCtx); if (inMultiDocumentTransaction) { assertIntersectingChunkHasNotMoved(opCtx, csr, insertedDoc); return; } auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); auto msm = MigrationSourceManager::get(csr, csrLock); if (msm) { msm->getCloner()->onInsertOp(opCtx, insertedDoc, opTime); } }
void OpObserverShardingImpl::shardObserveUpdateOp(OperationContext* opCtx, const NamespaceString nss, const BSONObj& updatedDoc, const repl::OpTime& opTime, const repl::OpTime& prePostImageOpTime, const bool inMultiDocumentTransaction) { auto* const css = CollectionShardingRuntime::get(opCtx, nss); css->checkShardVersionOrThrow(opCtx); auto msm = MigrationSourceManager::get(css); if (msm) { msm->getCloner()->onUpdateOp(opCtx, updatedDoc, opTime, prePostImageOpTime); } if (inMultiDocumentTransaction && repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime()) { assertIntersectingChunkHasNotMoved(opCtx, css, updatedDoc); } }
void OpObserverShardingImpl::shardObserveDeleteOp(OperationContext* opCtx, const NamespaceString nss, const BSONObj& documentKey, const repl::OpTime& opTime, const repl::OpTime& preImageOpTime, const bool inMultiDocumentTransaction) { auto* const csr = CollectionShardingRuntime::get(opCtx, nss); csr->checkShardVersionOrThrow(opCtx); if (inMultiDocumentTransaction) { assertIntersectingChunkHasNotMoved(opCtx, csr, documentKey); return; } auto csrLock = CollectionShardingRuntime::CSRLock::lock(opCtx, csr); auto msm = MigrationSourceManager::get(csr, csrLock); if (msm && getIsMigrating(opCtx)) { msm->getCloner()->onDeleteOp(opCtx, documentKey, opTime, preImageOpTime); } }
void OpObserverShardingImpl::shardObserveInsertOp(OperationContext* opCtx, const NamespaceString nss, const BSONObj& insertedDoc, const repl::OpTime& opTime, const bool fromMigrate, const bool inMultiDocumentTransaction) { auto* const css = (nss == NamespaceString::kSessionTransactionsTableNamespace || fromMigrate) ? nullptr : CollectionShardingRuntime::get(opCtx, nss); if (css) { css->checkShardVersionOrThrow(opCtx); auto msm = MigrationSourceManager::get(css); if (msm) { msm->getCloner()->onInsertOp(opCtx, insertedDoc, opTime); } if (inMultiDocumentTransaction && repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime()) { assertIntersectingChunkHasNotMoved(opCtx, css, insertedDoc); } } }