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 13:52:13 +0000
commita8cacc79c8294e62002a4ba474649e8cfcd92197 (patch)
tree58679ebfa0ef155319939dd88f49aa5c82f009c6
parente8cfc643a3d959896889046a47129684f5dbb89a (diff)
downloadmongo-a8cacc79c8294e62002a4ba474649e8cfcd92197.tar.gz
SERVER-48251 Update ‘getMaxKnownOpTime’ to return a Timestamp instead of an OpTime
-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 871ce4a70a6..bcb419f6c17 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 4796bd20a44..13844e8ee82 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -390,7 +390,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 aafb190a3f1..b2b5bff551d 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -236,7 +236,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);
if (isShardingAware || isConfig) {