summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@10gen.com>2020-05-15 15:11:44 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-19 16:23:41 +0000
commit5584c9212372ae515981000c2c124e5836780489 (patch)
treecc36c3322efcc3733916c0421cac8755a1b2898f
parent5ddf9db5635e4af2d1295bd2f1007e86d517c6c2 (diff)
downloadmongo-5584c9212372ae515981000c2c124e5836780489.tar.gz
SERVER-48251 Update ‘getMaxKnownOpTime’ to return a Timestamp instead of an OpTime
(cherry picked from commit a8cacc79c8294e62002a4ba474649e8cfcd92197)
-rw-r--r--src/mongo/db/pipeline/process_interface/common_process_interface.cpp4
-rw-r--r--src/mongo/db/repl/repl_client_info.h18
-rw-r--r--src/mongo/db/service_entry_point_common.cpp2
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp2
4 files changed, 14 insertions, 12 deletions
diff --git a/src/mongo/db/pipeline/process_interface/common_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_process_interface.cpp
index 79ca61de262..5cd9327fafa 100644
--- a/src/mongo/db/pipeline/process_interface/common_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/common_process_interface.cpp
@@ -163,8 +163,8 @@ void CommonProcessInterface::updateClientOperationTime(OperationContext* opCtx)
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
if (replCoord) {
auto operationTime = OperationTimeTracker::get(opCtx)->getMaxOperationTime();
- repl::OpTime opTime(operationTime.asTimestamp(), replCoord->getTerm());
- repl::ReplClientInfo::forClient(opCtx->getClient()).setLastProxyWriteOpTimeForward(opTime);
+ repl::ReplClientInfo::forClient(opCtx->getClient())
+ .setLastProxyWriteTimestampForward(operationTime.asTimestamp());
}
}
diff --git a/src/mongo/db/repl/repl_client_info.h b/src/mongo/db/repl/repl_client_info.h
index 51b953d2875..070e3ff6caa 100644
--- a/src/mongo/db/repl/repl_client_info.h
+++ b/src/mongo/db/repl/repl_client_info.h
@@ -61,20 +61,22 @@ public:
* Stores the operation time of the latest proxy write, that is, a write that was forwarded
* to and executed on a different node instead of being executed locally.
*/
- void setLastProxyWriteOpTimeForward(const OpTime& opTime) {
+ void setLastProxyWriteTimestampForward(const Timestamp& timestamp) {
// Only advance the operation time of the latest proxy write if it is greater than the one
// currently stored.
- if (opTime > _lastProxyWriteOpTime) {
- _lastProxyWriteOpTime = opTime;
+ if (timestamp > _lastProxyWriteTimestamp) {
+ _lastProxyWriteTimestamp = timestamp;
}
}
/**
- * Returns the greater of the times set by 'setLastOp()' and
- * 'setLastProxiedWriteOpTimeForward()'.
+ * Returns the greater of the timestamps set by 'setLastOp()' and
+ * 'setLastProxyWriteTimestampForward()'.
*/
- OpTime getMaxKnownOpTime() const {
- return _lastOp > _lastProxyWriteOpTime ? _lastOp : _lastProxyWriteOpTime;
+ Timestamp getMaxKnownOperationTime() const {
+ auto lastOpTimestamp = _lastOp.getTimestamp();
+ return lastOpTimestamp > _lastProxyWriteTimestamp ? lastOpTimestamp
+ : _lastProxyWriteTimestamp;
}
/**
@@ -109,7 +111,7 @@ private:
OpTime _lastOp = OpTime();
- OpTime _lastProxyWriteOpTime;
+ Timestamp _lastProxyWriteTimestamp;
};
} // namespace repl
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 55e50d2a6cd..1f100dab152 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -397,7 +397,7 @@ LogicalTime getClientOperationTime(OperationContext* opCtx) {
}
return LogicalTime(
- repl::ReplClientInfo::forClient(opCtx->getClient()).getMaxKnownOpTime().getTimestamp());
+ repl::ReplClientInfo::forClient(opCtx->getClient()).getMaxKnownOperationTime());
}
/**
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index 742368a4700..999dee4f932 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -252,7 +252,7 @@ public:
if (isReplSet) {
// Attach our own last opTime.
repl::OpTime lastOpTimeFromClient =
- repl::ReplClientInfo::forClient(opCtx->getClient()).getMaxKnownOpTime();
+ repl::ReplClientInfo::forClient(opCtx->getClient()).getLastOp();
replCoord->prepareReplMetadata(request.body, lastOpTimeFromClient, metadataBob);
// For commands from mongos, append some info to help getLastError(w) work.
// TODO: refactor out of here as part of SERVER-18236