summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/oplog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/oplog.cpp')
-rw-r--r--src/mongo/db/repl/oplog.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index f421603e99f..129f7ab16db 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -137,9 +137,6 @@ struct LocalOplogInfo {
// Synchronizes the section where a new Timestamp is generated and when it is registered in the
// storage engine.
stdx::mutex newOpMutex;
-
- // Used to generate "h" fields in pv0. Synchronized by newOpMutex.
- PseudoRandom hashGenerator{std::unique_ptr<SecureRandom>(SecureRandom::create())->nextInt64()};
};
const auto localOplogInfo = ServiceContext::declareDecoration<LocalOplogInfo>();
@@ -185,8 +182,7 @@ void _getNextOpTimes(OperationContext* opCtx,
}
for (std::size_t i = 0; i < count; i++) {
- slotsOut[i].opTime = {Timestamp(ts.asULL() + i), term};
- slotsOut[i].hash = oplogInfo.hashGenerator.nextInt64();
+ slotsOut[i] = {Timestamp(ts.asULL() + i), term};
}
}
@@ -449,7 +445,6 @@ OplogDocWriter _logOpWriter(OperationContext* opCtx,
const BSONObj* o2,
bool fromMigrate,
OpTime optime,
- long long hashNew,
Date_t wallTime,
const OperationSessionInfo& sessionInfo,
StmtId statementId,
@@ -461,7 +456,10 @@ OplogDocWriter _logOpWriter(OperationContext* opCtx,
b.append("ts", optime.getTimestamp());
if (optime.getTerm() != -1)
b.append("t", optime.getTerm());
- b.append("h", hashNew);
+
+ // Always write zero hash instead of using FCV to gate this for retryable writes
+ // and change stream, who expect to be able to read oplog across FCV's.
+ b.append("h", 0LL);
b.append("v", OplogEntry::kOplogVersion);
b.append("op", opstr);
b.append("ns", nss.ns());
@@ -608,7 +606,7 @@ OpTime logOp(OperationContext* opCtx,
auto const oplog = oplogInfo.oplog;
OplogSlot slot;
WriteUnitOfWork wuow(opCtx);
- if (oplogSlot.opTime.isNull()) {
+ if (oplogSlot.isNull()) {
_getNextOpTimes(opCtx, oplog, 1, &slot);
} else {
slot = oplogSlot;
@@ -621,8 +619,7 @@ OpTime logOp(OperationContext* opCtx,
obj,
o2,
fromMigrate,
- slot.opTime,
- slot.hash,
+ slot,
wallClockTime,
sessionInfo,
statementId,
@@ -630,10 +627,10 @@ OpTime logOp(OperationContext* opCtx,
prepare,
inTxn);
const DocWriter* basePtr = &writer;
- auto timestamp = slot.opTime.getTimestamp();
- _logOpsInner(opCtx, nss, &basePtr, &timestamp, 1, oplog, slot.opTime, wallClockTime);
+ auto timestamp = slot.getTimestamp();
+ _logOpsInner(opCtx, nss, &basePtr, &timestamp, 1, oplog, slot, wallClockTime);
wuow.commit();
- return slot.opTime;
+ return slot;
}
std::vector<OpTime> logInsertOps(OperationContext* opCtx,
@@ -686,7 +683,7 @@ std::vector<OpTime> logInsertOps(OperationContext* opCtx,
// Make a mutable copy.
auto insertStatementOplogSlot = begin[i].oplogSlot;
// Fetch optime now, if not already fetched.
- if (insertStatementOplogSlot.opTime.isNull()) {
+ if (insertStatementOplogSlot.isNull()) {
_getNextOpTimes(opCtx, oplog, 1, &insertStatementOplogSlot);
}
// Only 'applyOps' oplog entries can be prepared.
@@ -698,17 +695,16 @@ std::vector<OpTime> logInsertOps(OperationContext* opCtx,
begin[i].doc,
NULL,
fromMigrate,
- insertStatementOplogSlot.opTime,
- insertStatementOplogSlot.hash,
+ insertStatementOplogSlot,
wallClockTime,
sessionInfo,
begin[i].stmtId,
oplogLink,
prepare,
false /* inTxn */));
- oplogLink.prevOpTime = insertStatementOplogSlot.opTime;
+ oplogLink.prevOpTime = insertStatementOplogSlot;
timestamps[i] = oplogLink.prevOpTime.getTimestamp();
- opTimes.push_back(insertStatementOplogSlot.opTime);
+ opTimes.push_back(insertStatementOplogSlot);
}
MONGO_FAIL_POINT_BLOCK(sleepBetweenInsertOpTimeGenerationAndLogOp, customWait) {