diff options
author | Gabriel Marks <gabriel.marks@mongodb.com> | 2022-07-08 15:29:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-07-08 15:46:53 +0000 |
commit | 352885416d303d7fd64337457528a74296280151 (patch) | |
tree | 74b51bf0d3637d9d932a9b8df3b8b5e2d3c3d760 | |
parent | 0380c2736e2af6977362bda891e1a71b940cdd83 (diff) | |
download | mongo-352885416d303d7fd64337457528a74296280151.tar.gz |
Revert "SERVER-67532 Fail oplog server status section less"
This reverts commit 0380c2736e2af6977362bda891e1a71b940cdd83.
-rw-r--r-- | jstests/replsets/optime.js | 7 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_info.cpp | 14 |
2 files changed, 9 insertions, 12 deletions
diff --git a/jstests/replsets/optime.js b/jstests/replsets/optime.js index 7fdbd61c201..4ba7720a516 100644 --- a/jstests/replsets/optime.js +++ b/jstests/replsets/optime.js @@ -62,11 +62,8 @@ var replTest = new ReplSetTest( const nodes = replTest.startSet(); -// Tests that serverStatus oplog returns null timestamps if the oplog collection doesn't exist. -const zeroTs = new Timestamp(0, 0); -const oplogStatus = nodes[0].getDB('admin').serverStatus({oplog: true}).oplog; -assert.eq(oplogStatus.earliestOptime, zeroTs); -assert.eq(oplogStatus.latestOptime, zeroTs); +// Tests that serverStatus oplog returns an error if the oplog collection doesn't exist. +assert.commandFailedWithCode(nodes[0].getDB('admin').serverStatus({oplog: true}), 17347); replTest.initiate(); var master = replTest.getPrimary(); diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index 0e827661882..8d994dd93b2 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -275,10 +275,10 @@ public: BSONObjBuilder result; result.append("latestOptime", replCoord->getMyLastAppliedOpTime().getTimestamp()); - auto earliestOplogTimestampFetch = [&]() -> Timestamp { + auto earliestOplogTimestampFetch = [&]() -> StatusWith<Timestamp> { AutoGetOplog oplogRead(opCtx, OplogAccessMode::kRead); if (!oplogRead.getCollection()) { - return Timestamp(); + return StatusWith<Timestamp>(ErrorCodes::NamespaceNotFound, "oplog doesn't exist"); } // Try to get the lock. If it's already locked, immediately return null timestamp. @@ -305,13 +305,13 @@ public: return o["ts"].timestamp(); } } - if (!swEarliestOplogTimestamp.isOK()) { - return Timestamp(); - } - return swEarliestOplogTimestamp.getValue(); + + return swEarliestOplogTimestamp; }(); - result.append("earliestOptime", earliestOplogTimestampFetch); + uassert( + 17347, "Problem reading earliest entry from oplog", earliestOplogTimestampFetch.isOK()); + result.append("earliestOptime", earliestOplogTimestampFetch.getValue()); return result.obj(); } |