summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-04-05 17:33:12 -0400
committerBenety Goh <benety@mongodb.com>2019-04-05 17:33:31 -0400
commitf8a74023fa0034ee96668348904f6f1493c6fef0 (patch)
tree1cc760a4247f486669976bee897d2288f9c14f5e /src/mongo/db
parent20c33aa11ae2925d66b2df81e2ddb6813d81400a (diff)
downloadmongo-f8a74023fa0034ee96668348904f6f1493c6fef0.tar.gz
SERVER-40169 OplogEntry constructor accepts prepare argument
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/ops/write_ops_retryability_test.cpp10
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_test.cpp6
-rw-r--r--src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp3
-rw-r--r--src/mongo/db/repl/apply_ops_test.cpp3
-rw-r--r--src/mongo/db/repl/idempotency_test_fixture.cpp3
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp3
-rw-r--r--src/mongo/db/repl/multiapplier_test.cpp3
-rw-r--r--src/mongo/db/repl/oplog_entry.cpp12
-rw-r--r--src/mongo/db/repl/oplog_entry.h3
-rw-r--r--src/mongo/db/repl/replication_recovery_test.cpp3
-rw-r--r--src/mongo/db/repl/session_update_tracker.cpp3
-rw-r--r--src/mongo/db/repl/sync_source_resolver_test.cpp3
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp9
-rw-r--r--src/mongo/db/s/session_catalog_migration_destination_test.cpp36
-rw-r--r--src/mongo/db/s/session_catalog_migration_source.cpp3
-rw-r--r--src/mongo/db/s/session_catalog_migration_source_test.cpp15
-rw-r--r--src/mongo/db/transaction_history_iterator_test.cpp3
-rw-r--r--src/mongo/db/transaction_participant_retryable_writes_test.cpp3
-rw-r--r--src/mongo/db/transaction_participant_test.cpp3
19 files changed, 80 insertions, 47 deletions
diff --git a/src/mongo/db/ops/write_ops_retryability_test.cpp b/src/mongo/db/ops/write_ops_retryability_test.cpp
index 05c4828dae1..45a4305f012 100644
--- a/src/mongo/db/ops/write_ops_retryability_test.cpp
+++ b/src/mongo/db/ops/write_ops_retryability_test.cpp
@@ -58,7 +58,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
BSONObj oField,
boost::optional<BSONObj> o2Field = boost::none,
boost::optional<repl::OpTime> preImageOpTime = boost::none,
- boost::optional<repl::OpTime> postImageOpTime = boost::none) {
+ boost::optional<repl::OpTime> postImageOpTime = boost::none,
+ boost::optional<bool> prepare = boost::none) {
return repl::OplogEntry(opTime, // optime
boost::none, // hash
opType, // opType
@@ -72,9 +73,10 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
boost::none, // upsert
boost::none, // wall clock time
boost::none, // statement id
- boost::none, // optime of previous write within same transaction
- preImageOpTime, // pre-image optime
- postImageOpTime); // post-image optime
+ boost::none, // optime of previous write within same transaction
+ preImageOpTime, // pre-image optime
+ postImageOpTime, // post-image optime
+ prepare); // prepare
}
TEST_F(WriteOpsRetryability, ParseOplogEntryForUpdate) {
diff --git a/src/mongo/db/pipeline/document_source_change_stream_test.cpp b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
index 2465b94da23..686b4a51670 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_test.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
@@ -310,7 +310,8 @@ public:
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
};
@@ -952,7 +953,8 @@ TEST_F(ChangeStreamStageTest, CommitCommandReturnsOperationsFromPreparedTransact
boost::none, // statement id
kPreparedTransactionOpTime, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
// When the DocumentSourceChangeStreamTransform sees the "commitTransaction" oplog entry, we
// expect it to return the insert op within our 'preparedApplyOps' oplog entry.
diff --git a/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp b/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
index 06f5b9cfdeb..7d39509d971 100644
--- a/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
+++ b/src/mongo/db/repl/abstract_oplog_fetcher_test_fixture.cpp
@@ -62,7 +62,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
} // namespace
diff --git a/src/mongo/db/repl/apply_ops_test.cpp b/src/mongo/db/repl/apply_ops_test.cpp
index b6d1b6e72dd..019bdd59b4c 100644
--- a/src/mongo/db/repl/apply_ops_test.cpp
+++ b/src/mongo/db/repl/apply_ops_test.cpp
@@ -366,7 +366,8 @@ OplogEntry makeOplogEntry(OpTypeEnum opType, const BSONObj& oField) {
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
TEST_F(ApplyOpsTest, ExtractOperationsReturnsTypeMismatchIfNotCommand) {
diff --git a/src/mongo/db/repl/idempotency_test_fixture.cpp b/src/mongo/db/repl/idempotency_test_fixture.cpp
index cd8ed1467f2..692d667bafe 100644
--- a/src/mongo/db/repl/idempotency_test_fixture.cpp
+++ b/src/mongo/db/repl/idempotency_test_fixture.cpp
@@ -91,7 +91,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
stmtId, // statement id
prevOpTime, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
} // namespace
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index ca111c8c9a1..2a30780c6e0 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -581,7 +581,8 @@ OplogEntry makeOplogEntry(int t,
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
BSONObj makeOplogEntryObj(int t,
diff --git a/src/mongo/db/repl/multiapplier_test.cpp b/src/mongo/db/repl/multiapplier_test.cpp
index bafa8eef774..dbf80d9bc19 100644
--- a/src/mongo/db/repl/multiapplier_test.cpp
+++ b/src/mongo/db/repl/multiapplier_test.cpp
@@ -81,7 +81,8 @@ OplogEntry makeOplogEntry(int ts) {
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
TEST_F(MultiApplierTest, InvalidConstruction) {
diff --git a/src/mongo/db/repl/oplog_entry.cpp b/src/mongo/db/repl/oplog_entry.cpp
index af39c06b8ed..0ed3b9afed6 100644
--- a/src/mongo/db/repl/oplog_entry.cpp
+++ b/src/mongo/db/repl/oplog_entry.cpp
@@ -107,7 +107,8 @@ BSONObj makeOplogEntryDoc(OpTime opTime,
const boost::optional<StmtId>& statementId,
const boost::optional<OpTime>& prevWriteOpTimeInTransaction,
const boost::optional<OpTime>& preImageOpTime,
- const boost::optional<OpTime>& postImageOpTime) {
+ const boost::optional<OpTime>& postImageOpTime,
+ const boost::optional<bool>& prepare) {
BSONObjBuilder builder;
sessionInfo.serialize(&builder);
builder.append(OplogEntryBase::kTimestampFieldName, opTime.getTimestamp());
@@ -150,6 +151,9 @@ BSONObj makeOplogEntryDoc(OpTime opTime,
const BSONObj localObject = postImageOpTime.get().toBSON();
builder.append(OplogEntryBase::kPostImageOpTimeFieldName, localObject);
}
+ if (prepare) {
+ builder.append(OplogEntryBase::kPrepareFieldName, prepare.get());
+ }
return builder.obj();
}
@@ -233,7 +237,8 @@ OplogEntry::OplogEntry(OpTime opTime,
const boost::optional<StmtId>& statementId,
const boost::optional<OpTime>& prevWriteOpTimeInTransaction,
const boost::optional<OpTime>& preImageOpTime,
- const boost::optional<OpTime>& postImageOpTime)
+ const boost::optional<OpTime>& postImageOpTime,
+ const boost::optional<bool>& prepare)
: OplogEntry(makeOplogEntryDoc(opTime,
hash,
opType,
@@ -249,7 +254,8 @@ OplogEntry::OplogEntry(OpTime opTime,
statementId,
prevWriteOpTimeInTransaction,
preImageOpTime,
- postImageOpTime)) {}
+ postImageOpTime,
+ prepare)) {}
bool OplogEntry::isCommand() const {
return getOpType() == OpTypeEnum::kCommand;
diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h
index da61939556b..5dee90fec32 100644
--- a/src/mongo/db/repl/oplog_entry.h
+++ b/src/mongo/db/repl/oplog_entry.h
@@ -126,7 +126,8 @@ public:
const boost::optional<StmtId>& statementId,
const boost::optional<OpTime>& prevWriteOpTimeInTransaction,
const boost::optional<OpTime>& preImageOpTime,
- const boost::optional<OpTime>& postImageOpTime);
+ const boost::optional<OpTime>& postImageOpTime,
+ const boost::optional<bool>& prepare);
// DEPRECATED: This constructor can throw. Use static parse method instead.
explicit OplogEntry(BSONObj raw);
diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp
index 2fa8c80d0ff..c2b01b1e55f 100644
--- a/src/mongo/db/repl/replication_recovery_test.cpp
+++ b/src/mongo/db/repl/replication_recovery_test.cpp
@@ -239,7 +239,8 @@ repl::OplogEntry _makeOplogEntry(repl::OpTime opTime,
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
/**
diff --git a/src/mongo/db/repl/session_update_tracker.cpp b/src/mongo/db/repl/session_update_tracker.cpp
index 59d412b5b07..28a78ae7449 100644
--- a/src/mongo/db/repl/session_update_tracker.cpp
+++ b/src/mongo/db/repl/session_update_tracker.cpp
@@ -111,7 +111,8 @@ boost::optional<repl::OplogEntry> createMatchingTransactionTableUpdate(
boost::none, // statementId
boost::none, // prevWriteOpTime
boost::none, // preImangeOpTime
- boost::none // postImageOpTime
+ boost::none, // postImageOpTime
+ boost::none // prepare
);
}
diff --git a/src/mongo/db/repl/sync_source_resolver_test.cpp b/src/mongo/db/repl/sync_source_resolver_test.cpp
index 9e4761051bf..83ee5a76136 100644
--- a/src/mongo/db/repl/sync_source_resolver_test.cpp
+++ b/src/mongo/db/repl/sync_source_resolver_test.cpp
@@ -314,7 +314,8 @@ BSONObj _makeOplogEntry(Timestamp ts, long long term) {
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none) // post-image optime
+ boost::none, // post-image optime
+ boost::none) // prepare
.toBSON();
}
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index abc2ad364dc..f7b11feda49 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -99,7 +99,8 @@ OplogEntry makeOplogEntry(OpTypeEnum opType, NamespaceString nss, OptionalCollec
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
/**
@@ -2187,7 +2188,8 @@ public:
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
/**
@@ -2215,7 +2217,8 @@ public:
boost::none, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
void checkTxnTable(const OperationSessionInfo& sessionInfo,
diff --git a/src/mongo/db/s/session_catalog_migration_destination_test.cpp b/src/mongo/db/s/session_catalog_migration_destination_test.cpp
index 2bdd5d3b62a..ace7f227324 100644
--- a/src/mongo/db/s/session_catalog_migration_destination_test.cpp
+++ b/src/mongo/db/s/session_catalog_migration_destination_test.cpp
@@ -88,23 +88,25 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
boost::optional<Date_t> wallClockTime,
boost::optional<StmtId> stmtId,
boost::optional<repl::OpTime> preImageOpTime = boost::none,
- boost::optional<repl::OpTime> postImageOpTime = boost::none) {
- return repl::OplogEntry(opTime, // optime
- 0, // hash
- opType, // opType
- kNs, // namespace
- boost::none, // uuid
- boost::none, // fromMigrate
- 0, // version
- object, // o
- object2, // o2
- sessionInfo, // sessionInfo
- boost::none, // isUpsert
- wallClockTime, // wall clock time
- stmtId, // statement id
- boost::none, // optime of previous write within same transaction
- preImageOpTime, // pre-image optime
- postImageOpTime); // post-image optime
+ boost::optional<repl::OpTime> postImageOpTime = boost::none,
+ boost::optional<bool> prepare = boost::none) {
+ return repl::OplogEntry(opTime, // optime
+ 0, // hash
+ opType, // opType
+ kNs, // namespace
+ boost::none, // uuid
+ boost::none, // fromMigrate
+ 0, // version
+ object, // o
+ object2, // o2
+ sessionInfo, // sessionInfo
+ boost::none, // isUpsert
+ wallClockTime, // wall clock time
+ stmtId, // statement id
+ boost::none, // optime of previous write within same transaction
+ preImageOpTime, // pre-image optime
+ postImageOpTime, // post-image optime
+ prepare); // prepare
}
repl::OplogEntry extractInnerOplog(const repl::OplogEntry& oplog) {
diff --git a/src/mongo/db/s/session_catalog_migration_source.cpp b/src/mongo/db/s/session_catalog_migration_source.cpp
index 3d37920e59c..c60b596d123 100644
--- a/src/mongo/db/s/session_catalog_migration_source.cpp
+++ b/src/mongo/db/s/session_catalog_migration_source.cpp
@@ -101,7 +101,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
statementId, // statement id
boost::none, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
/**
diff --git a/src/mongo/db/s/session_catalog_migration_source_test.cpp b/src/mongo/db/s/session_catalog_migration_source_test.cpp
index f46461761af..352877a8edf 100644
--- a/src/mongo/db/s/session_catalog_migration_source_test.cpp
+++ b/src/mongo/db/s/session_catalog_migration_source_test.cpp
@@ -61,7 +61,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
StmtId stmtId,
repl::OpTime prevWriteOpTimeInTransaction,
boost::optional<repl::OpTime> preImageOpTime,
- boost::optional<repl::OpTime> postImageOpTime) {
+ boost::optional<repl::OpTime> postImageOpTime,
+ boost::optional<bool> prepare) {
return repl::OplogEntry(
opTime, // optime
0, // hash
@@ -78,7 +79,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
stmtId, // statement id
prevWriteOpTimeInTransaction, // optime of previous write within same transaction
preImageOpTime, // pre-image optime
- postImageOpTime); // post-image optime
+ postImageOpTime, // post-image optime
+ prepare); // prepare
}
repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
@@ -89,7 +91,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
StmtId stmtId,
repl::OpTime prevWriteOpTimeInTransaction,
boost::optional<repl::OpTime> preImageOpTime = boost::none,
- boost::optional<repl::OpTime> postImageOpTime = boost::none) {
+ boost::optional<repl::OpTime> postImageOpTime = boost::none,
+ boost::optional<bool> prepare = boost::none) {
return makeOplogEntry(opTime,
opType,
kNs,
@@ -99,7 +102,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
stmtId,
prevWriteOpTimeInTransaction,
preImageOpTime,
- postImageOpTime);
+ postImageOpTime,
+ prepare);
}
TEST_F(SessionCatalogMigrationSourceTest, NoSessionsToTransferShouldNotHaveOplog) {
@@ -368,7 +372,8 @@ TEST_F(SessionCatalogMigrationSourceTest, OplogWithOtherNsShouldBeIgnored) {
1, // statement id
repl::OpTime(Timestamp(0, 0), 0), // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // pre-image optime
+ boost::none); // prepare
insertOplogEntry(entry2);
SessionTxnRecord sessionRecord2;
diff --git a/src/mongo/db/transaction_history_iterator_test.cpp b/src/mongo/db/transaction_history_iterator_test.cpp
index b64f5338ba3..1e4e5a94720 100644
--- a/src/mongo/db/transaction_history_iterator_test.cpp
+++ b/src/mongo/db/transaction_history_iterator_test.cpp
@@ -77,7 +77,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
boost::none, // statement id
prevWriteOpTimeInTransaction, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
} // namespace
diff --git a/src/mongo/db/transaction_participant_retryable_writes_test.cpp b/src/mongo/db/transaction_participant_retryable_writes_test.cpp
index 69220e0813e..ab88c014f73 100644
--- a/src/mongo/db/transaction_participant_retryable_writes_test.cpp
+++ b/src/mongo/db/transaction_participant_retryable_writes_test.cpp
@@ -81,7 +81,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
stmtId, // statement id
prevWriteOpTimeInTransaction, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
class OpObserverMock : public OpObserverNoop {
diff --git a/src/mongo/db/transaction_participant_test.cpp b/src/mongo/db/transaction_participant_test.cpp
index 005211f55c7..33c6c3b8788 100644
--- a/src/mongo/db/transaction_participant_test.cpp
+++ b/src/mongo/db/transaction_participant_test.cpp
@@ -87,7 +87,8 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime,
stmtId, // statement id
prevWriteOpTimeInTransaction, // optime of previous write within same transaction
boost::none, // pre-image optime
- boost::none); // post-image optime
+ boost::none, // post-image optime
+ boost::none); // prepare
}
class OpObserverMock : public OpObserverNoop {