summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorJason Chan <jason.chan@10gen.com>2021-05-05 10:43:30 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-05 20:01:41 +0000
commit8447dea32f0afdc0cfb8bf9bd1ca040ac6850c48 (patch)
tree93bb1b0bda2f2173524e8cb76108e786a1c7aed4 /src/mongo/db/repl
parent778dcc77d9a5c3f2e8463c5b8f9ceafeeeb302b8 (diff)
downloadmongo-8447dea32f0afdc0cfb8bf9bd1ca040ac6850c48.tar.gz
SERVER-56373 Add storeFindAndModifyImagesInOplog parameter and introduce 'needsRetryImage' field to oplog entries.
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/oplog.cpp16
-rw-r--r--src/mongo/db/repl/oplog.h4
-rw-r--r--src/mongo/db/repl/oplog_entry.idl13
-rw-r--r--src/mongo/db/repl/oplog_test.cpp6
4 files changed, 32 insertions, 7 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 8b1bf69fed5..ce2cf2ed50b 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -360,7 +360,8 @@ OplogDocWriter _logOpWriter(OperationContext* opCtx,
Date_t wallTime,
const OperationSessionInfo& sessionInfo,
StmtId statementId,
- const OplogLink& oplogLink) {
+ const OplogLink& oplogLink,
+ boost::optional<repl::RetryImageEnum> needsRetryImage) {
BSONObjBuilder b(256);
b.append("ts", optime.getTimestamp());
@@ -379,6 +380,10 @@ OplogDocWriter _logOpWriter(OperationContext* opCtx,
if (o2)
b.append("o2", *o2);
+ if (needsRetryImage) {
+ b.append("needsRetryImage", repl::RetryImage_serializer(*needsRetryImage));
+ }
+
invariant(wallTime != Date_t{});
b.appendDate("wall", wallTime);
@@ -458,7 +463,8 @@ OpTime logOp(OperationContext* opCtx,
const OperationSessionInfo& sessionInfo,
StmtId statementId,
const OplogLink& oplogLink,
- const OplogSlot& oplogSlot) {
+ const OplogSlot& oplogSlot,
+ boost::optional<repl::RetryImageEnum> needsRetryImage) {
auto replCoord = ReplicationCoordinator::get(opCtx);
// For commands, the test below is on the command ns and therefore does not check for
// specific namespaces such as system.profile. This is the caller's responsibility.
@@ -499,7 +505,8 @@ OpTime logOp(OperationContext* opCtx,
wallClockTime,
sessionInfo,
statementId,
- oplogLink);
+ oplogLink,
+ needsRetryImage);
const DocWriter* basePtr = &writer;
auto timestamp = slot.opTime.getTimestamp();
_logOpsInner(opCtx, nss, &basePtr, &timestamp, 1, oplog, slot.opTime);
@@ -571,7 +578,8 @@ std::vector<OpTime> logInsertOps(OperationContext* opCtx,
wallClockTime,
sessionInfo,
begin[i].stmtId,
- oplogLink));
+ oplogLink,
+ {}));
oplogLink.prevOpTime = insertStatementOplogSlot.opTime;
timestamps[i] = oplogLink.prevOpTime.getTimestamp();
opTimes.push_back(insertStatementOplogSlot.opTime);
diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h
index bda617909c4..40cd7fea97e 100644
--- a/src/mongo/db/repl/oplog.h
+++ b/src/mongo/db/repl/oplog.h
@@ -38,6 +38,7 @@
#include "mongo/bson/timestamp.h"
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/logical_session_id.h"
+#include "mongo/db/repl/oplog_entry_gen.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/stdx/functional.h"
@@ -144,7 +145,8 @@ OpTime logOp(OperationContext* opCtx,
const OperationSessionInfo& sessionInfo,
StmtId stmtId,
const OplogLink& oplogLink,
- const OplogSlot& oplogSlot);
+ const OplogSlot& oplogSlot,
+ boost::optional<repl::RetryImageEnum> needsRetryImage);
// Flush out the cached pointer to the oplog.
// Used by the closeDatabase command to ensure we don't cache closed things.
diff --git a/src/mongo/db/repl/oplog_entry.idl b/src/mongo/db/repl/oplog_entry.idl
index f7a7fa6f949..0a30146c53f 100644
--- a/src/mongo/db/repl/oplog_entry.idl
+++ b/src/mongo/db/repl/oplog_entry.idl
@@ -46,6 +46,13 @@ enums:
kUpdate: "u"
kDelete: "d"
kNoop: "n"
+ RetryImage:
+ description: "Dictates whether a pre-image or post-image is to be stored on behalf of this
+ retryable write."
+ type: string
+ values:
+ kPreImage: "preImage"
+ kPostImage: "postImage"
structs:
ReplOperation:
@@ -141,3 +148,9 @@ structs:
optional: true
description: "The optime of another oplog entry that contains the document
after an update was applied."
+
+ needsRetryImage:
+ type: RetryImage
+ optional: true
+ description: "Identifies whether a secondary should store a pre-image or post-image
+ associated with this oplog entry."
diff --git a/src/mongo/db/repl/oplog_test.cpp b/src/mongo/db/repl/oplog_test.cpp
index d98220eebb9..dbc8b434885 100644
--- a/src/mongo/db/repl/oplog_test.cpp
+++ b/src/mongo/db/repl/oplog_test.cpp
@@ -113,7 +113,8 @@ TEST_F(OplogTest, LogOpReturnsOpTimeOnSuccessfulInsertIntoOplogCollection) {
{},
kUninitializedStmtId,
{},
- OplogSlot());
+ OplogSlot(),
+ {});
ASSERT_FALSE(opTime.isNull());
wunit.commit();
}
@@ -236,7 +237,8 @@ OpTime _logOpNoopWithMsg(OperationContext* opCtx,
{},
kUninitializedStmtId,
{},
- OplogSlot());
+ OplogSlot(),
+ {});
ASSERT_FALSE(opTime.isNull());
ASSERT(opTimeNssMap->find(opTime) == opTimeNssMap->end())