summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2021-10-20 22:38:21 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-21 19:23:48 +0000
commite72979cbed329db5b8dd9aa438001cf89914934e (patch)
treeb40a9fcd7f04e55543eecb78e505bbbf64b9f7d7
parente04ed6b3ab9893c6fabe377b565fc177c4715d87 (diff)
downloadmongo-e72979cbed329db5b8dd9aa438001cf89914934e.tar.gz
SERVER-60877: Correct an unintended heavy object copy.
(cherry picked from commit 7623389baa25b3ac9ae5e74d2edee0d67a42bf25)
-rw-r--r--src/mongo/db/op_observer_impl.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index 7a5bd26be05..32b9f1ec877 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -167,12 +167,12 @@ struct OpTimeBundle {
*/
OpTimeBundle replLogUpdate(OperationContext* opCtx,
const OplogUpdateEntryArgs& args,
- MutableOplogEntry oplogEntry) {
- oplogEntry.setNss(args.nss);
- oplogEntry.setUuid(args.uuid);
+ MutableOplogEntry* oplogEntry) {
+ oplogEntry->setNss(args.nss);
+ oplogEntry->setUuid(args.uuid);
repl::OplogLink oplogLink;
- repl::appendOplogEntryChainInfo(opCtx, &oplogEntry, &oplogLink, args.updateArgs.stmtIds);
+ repl::appendOplogEntryChainInfo(opCtx, oplogEntry, &oplogLink, args.updateArgs.stmtIds);
OpTimeBundle opTimes;
// We never want to store pre- or post- images when we're migrating oplog entries from another
@@ -180,11 +180,11 @@ OpTimeBundle replLogUpdate(OperationContext* opCtx,
const auto& migrationRecipientInfo = repl::tenantMigrationRecipientInfo(opCtx);
const auto storePreImageInOplogForRetryableWrite =
(args.updateArgs.storeDocOption == CollectionUpdateArgs::StoreDocOption::PreImage &&
- opCtx->getTxnNumber() && !oplogEntry.getNeedsRetryImage());
+ opCtx->getTxnNumber() && !oplogEntry->getNeedsRetryImage());
if ((storePreImageInOplogForRetryableWrite ||
args.updateArgs.preImageRecordingEnabledForCollection) &&
!migrationRecipientInfo) {
- MutableOplogEntry noopEntry = oplogEntry;
+ MutableOplogEntry noopEntry = *oplogEntry;
invariant(args.updateArgs.preImageDoc);
noopEntry.setOpType(repl::OpTypeEnum::kNoop);
noopEntry.setObject(*args.updateArgs.preImageDoc);
@@ -196,8 +196,8 @@ OpTimeBundle replLogUpdate(OperationContext* opCtx,
// This case handles storing the post image for retryable findAndModify's.
if (args.updateArgs.storeDocOption == CollectionUpdateArgs::StoreDocOption::PostImage &&
- opCtx->getTxnNumber() && !migrationRecipientInfo && !oplogEntry.getNeedsRetryImage()) {
- MutableOplogEntry noopEntry = oplogEntry;
+ opCtx->getTxnNumber() && !migrationRecipientInfo && !oplogEntry->getNeedsRetryImage()) {
+ MutableOplogEntry noopEntry = *oplogEntry;
noopEntry.setOpType(repl::OpTypeEnum::kNoop);
noopEntry.setObject(args.updateArgs.updatedDoc);
oplogLink.postImageOpTime = logOperation(opCtx, &noopEntry);
@@ -205,17 +205,17 @@ OpTimeBundle replLogUpdate(OperationContext* opCtx,
opTimes.prePostImageOpTime = oplogLink.postImageOpTime;
}
- oplogEntry.setOpType(repl::OpTypeEnum::kUpdate);
- oplogEntry.setObject(args.updateArgs.update);
- oplogEntry.setObject2(args.updateArgs.criteria);
- oplogEntry.setFromMigrateIfTrue(args.updateArgs.source == OperationSource::kFromMigrate);
+ oplogEntry->setOpType(repl::OpTypeEnum::kUpdate);
+ oplogEntry->setObject(args.updateArgs.update);
+ oplogEntry->setObject2(args.updateArgs.criteria);
+ oplogEntry->setFromMigrateIfTrue(args.updateArgs.source == OperationSource::kFromMigrate);
// oplogLink could have been changed to include pre/postImageOpTime by the previous no-op write.
- repl::appendOplogEntryChainInfo(opCtx, &oplogEntry, &oplogLink, args.updateArgs.stmtIds);
+ repl::appendOplogEntryChainInfo(opCtx, oplogEntry, &oplogLink, args.updateArgs.stmtIds);
if (args.updateArgs.oplogSlot) {
- oplogEntry.setOpTime(*args.updateArgs.oplogSlot);
+ oplogEntry->setOpTime(*args.updateArgs.oplogSlot);
}
- opTimes.writeOpTime = logOperation(opCtx, &oplogEntry);
- opTimes.wallClockTime = oplogEntry.getWallClockTime();
+ opTimes.writeOpTime = logOperation(opCtx, oplogEntry);
+ opTimes.wallClockTime = oplogEntry->getWallClockTime();
return opTimes;
}
@@ -655,7 +655,7 @@ void OpObserverImpl::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArg
}
}
- opTime = replLogUpdate(opCtx, args, oplogEntry);
+ opTime = replLogUpdate(opCtx, args, &oplogEntry);
if (oplogEntry.getNeedsRetryImage()) {
// If the oplog entry has `needsRetryImage`, copy the image into image collection.