diff options
author | Misha Tyulenev <misha@mongodb.com> | 2017-07-12 15:08:17 -0400 |
---|---|---|
committer | Misha Tyulenev <misha@mongodb.com> | 2017-07-12 15:08:35 -0400 |
commit | c1a3dd7fc02656a952d6f99f08c0e539bae805d1 (patch) | |
tree | f70f254c0093e1a59d93839bd5e864dbf6b460d0 | |
parent | 5de27a9379678e93068d01f708d7ec8cc4fc35f4 (diff) | |
download | mongo-c1a3dd7fc02656a952d6f99f08c0e539bae805d1.tar.gz |
SERVER-29988 operationTime returned to mongo shell can not be uninitialized
-rw-r--r-- | src/mongo/s/commands/strategy.cpp | 4 | ||||
-rw-r--r-- | src/mongo/shell/mongo.js | 3 |
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)) { |