diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2021-10-20 22:38:21 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-21 19:04:42 +0000 |
commit | f5cafef0a26d042c439d92029429696160c2b98f (patch) | |
tree | 7aa3a79a3e51179972d28f6c29991ce987c123cc | |
parent | a022feadf02806f9be151bc89a12682731d4ac1b (diff) | |
download | mongo-f5cafef0a26d042c439d92029429696160c2b98f.tar.gz |
SERVER-60877: Correct an unintended heavy object copy.
(cherry picked from commit 7623389baa25b3ac9ae5e74d2edee0d67a42bf25)
-rw-r--r-- | src/mongo/db/op_observer_impl.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index cb9bab81b09..498c2002056 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -156,20 +156,20 @@ 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.stmtId); + repl::appendOplogEntryChainInfo(opCtx, oplogEntry, &oplogLink, args.updateArgs.stmtId); OpTimeBundle opTimes; const auto storePreImageInOplogForRetryableWrite = (args.updateArgs.storeDocOption == CollectionUpdateArgs::StoreDocOption::PreImage && - opCtx->getTxnNumber() && !oplogEntry.getNeedsRetryImage()); + opCtx->getTxnNumber() && !oplogEntry->getNeedsRetryImage()); if (storePreImageInOplogForRetryableWrite || args.updateArgs.preImageRecordingEnabledForCollection) { - MutableOplogEntry noopEntry = oplogEntry; + MutableOplogEntry noopEntry = *oplogEntry; invariant(args.updateArgs.preImageDoc); noopEntry.setOpType(repl::OpTypeEnum::kNoop); noopEntry.setObject(*args.updateArgs.preImageDoc); @@ -181,8 +181,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() && !oplogEntry.getNeedsRetryImage()) { - MutableOplogEntry noopEntry = oplogEntry; + opCtx->getTxnNumber() && !oplogEntry->getNeedsRetryImage()) { + MutableOplogEntry noopEntry = *oplogEntry; noopEntry.setOpType(repl::OpTypeEnum::kNoop); noopEntry.setObject(args.updateArgs.updatedDoc); oplogLink.postImageOpTime = logOperation(opCtx, &noopEntry); @@ -190,14 +190,14 @@ 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.fromMigrate); + oplogEntry->setOpType(repl::OpTypeEnum::kUpdate); + oplogEntry->setObject(args.updateArgs.update); + oplogEntry->setObject2(args.updateArgs.criteria); + oplogEntry->setFromMigrateIfTrue(args.updateArgs.fromMigrate); // oplogLink could have been changed to include pre/postImageOpTime by the previous no-op write. - repl::appendOplogEntryChainInfo(opCtx, &oplogEntry, &oplogLink, args.updateArgs.stmtId); - opTimes.writeOpTime = logOperation(opCtx, &oplogEntry); - opTimes.wallClockTime = oplogEntry.getWallClockTime(); + repl::appendOplogEntryChainInfo(opCtx, oplogEntry, &oplogLink, args.updateArgs.stmtId); + opTimes.writeOpTime = logOperation(opCtx, oplogEntry); + opTimes.wallClockTime = oplogEntry->getWallClockTime(); return opTimes; } @@ -548,7 +548,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. |