summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/s/commands/strategy.cpp4
-rw-r--r--src/mongo/shell/mongo.js3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 2b320595c4d..c4f20e93b82 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -136,7 +136,9 @@ void appendRequiredFieldsToResponse(OperationContext* opCtx, BSONObjBuilder* res
// Add operationTime.
if (auto tracker = OperationTimeTracker::get(opCtx)) {
auto operationTime = OperationTimeTracker::get(opCtx)->getMaxOperationTime();
- responseBuilder->append(kOperationTime, operationTime.asTimestamp());
+ if (operationTime != LogicalTime::kUninitialized) {
+ responseBuilder->append(kOperationTime, operationTime.asTimestamp());
+ }
} else if (currentTime.getTime() != LogicalTime::kUninitialized) {
// If we don't know the actual operation time, use the cluster time instead. This is
// safe but not optimal because we can always return a later operation time than actual.
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js
index 5ed8ababdf6..d72bcbc0de8 100644
--- a/src/mongo/shell/mongo.js
+++ b/src/mongo/shell/mongo.js
@@ -534,6 +534,9 @@ Mongo.prototype.unsetWriteConcern = function() {
* Sets the operationTime.
*/
Mongo.prototype.setOperationTime = function(operationTime) {
+ if (operationTime === Timestamp(0, 0)) {
+ throw Error("Attempt to set an uninitiated operationTime");
+ }
if (this._operationTime === undefined || this._operationTime === null ||
(typeof operationTime === "object" &&
bsonWoCompare(operationTime, this._operationTime) === 1)) {