summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2018-12-14 22:24:49 -0500
committerA. Jesse Jiryu Davis <jesse@mongodb.com>2018-12-17 13:04:53 -0500
commit105acca0d443f9a47c1a5bd608fd7133840a58dd (patch)
tree5a8d739386d7e4502ff4314c4bcae3cd32bbf408
parentb552f4281de9d9127b97aed613fadd0a697ac244 (diff)
downloadmongo-105acca0d443f9a47c1a5bd608fd7133840a58dd.tar.gz
SERVER-38425 Use oplogReplay for oplog visibility queryr3.2.22-rc0r3.2.22
-rw-r--r--jstests/libs/check_log.js4
-rw-r--r--jstests/replsets/initial_sync_oplog_visibility.js14
-rw-r--r--src/mongo/db/repl/oplogreader.h6
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp2
4 files changed, 21 insertions, 5 deletions
diff --git a/jstests/libs/check_log.js b/jstests/libs/check_log.js
index edfd8b1d5cf..23b9b91b227 100644
--- a/jstests/libs/check_log.js
+++ b/jstests/libs/check_log.js
@@ -29,7 +29,7 @@ var checkLog;
* the provided 'msg' is found in the logs, or 5 minutes have elapsed. Throws an exception
* on timeout.
*/
- var contains = function(conn, msg) {
+ var contains = function(conn, msg, timeoutSeconds = 5 * 60) {
assert.soon(
function() {
var logMessages = getGlobalLog(conn);
@@ -44,7 +44,7 @@ var checkLog;
return false;
},
'Could not find log entries containing the following message: ' + msg,
- 5 * 60 * 1000,
+ timeoutSeconds * 1000,
300);
};
diff --git a/jstests/replsets/initial_sync_oplog_visibility.js b/jstests/replsets/initial_sync_oplog_visibility.js
index 9002a5f9b23..06eadc861b3 100644
--- a/jstests/replsets/initial_sync_oplog_visibility.js
+++ b/jstests/replsets/initial_sync_oplog_visibility.js
@@ -11,6 +11,8 @@
replTest.startSet();
replTest.initiate();
var primary = replTest.getPrimary();
+ assert.commandWorked(
+ primary.adminCommand({setParameter: 1, logComponentVerbosity: {query: 3}}));
var firstColl = "hangColl";
var secondColl = "secondColl";
@@ -48,5 +50,17 @@
awaitInsertShell();
replTest.awaitSecondaryNodes();
+ // The oplog visibility query should use an oplog-optimized plan. Check vaguely for this by
+ // awaiting a characteristic log message for each storage engine - we at least know that *some*
+ // query used the optimal plan around the time of the visibility query.
+ const timeoutSeconds = 30;
+ if (primary.adminCommand("serverStatus").storageEngine.name === "wiredTiger") {
+ jsTestLog("Checking for log message about 'direct oplog seek' query plan.");
+ checkLog.contains(primary, "Using direct oplog seek", timeoutSeconds);
+ } else if (primary.adminCommand("serverStatus").storageEngine.name === "mmapv1") {
+ jsTestLog("Checking for log message about 'Using OplogStart stage'.");
+ checkLog.contains(primary, "Using OplogStart stage", timeoutSeconds);
+ }
+
replTest.stopSet();
})(); \ No newline at end of file
diff --git a/src/mongo/db/repl/oplogreader.h b/src/mongo/db/repl/oplogreader.h
index 3c983b007fc..3aeb5b7293d 100644
--- a/src/mongo/db/repl/oplogreader.h
+++ b/src/mongo/db/repl/oplogreader.h
@@ -84,8 +84,10 @@ public:
DBClientConnection* conn() {
return _conn.get();
}
- BSONObj findOne(const char* ns, const Query& q) {
- return conn()->findOne(ns, q, 0, QueryOption_SlaveOk);
+ BSONObj findOne(const char* ns,
+ const Query& q,
+ QueryOptions options = static_cast<QueryOptions>(0)) {
+ return conn()->findOne(ns, q, 0, QueryOption_SlaveOk | options);
}
BSONObj getLastOp(const std::string& ns) {
return findOne(ns.c_str(), Query().sort(reverseNaturalObj));
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index 3f8ff685de9..42a230e3d8a 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -368,7 +368,7 @@ Status _initialSync() {
BSONObjBuilder queryBob;
queryBob.append("ts", gte.done());
const BSONObj& query = queryBob.done();
- BSONObj lastOpConfirm = r.findOne(rsOplogName.c_str(), query);
+ BSONObj lastOpConfirm = r.findOne(rsOplogName.c_str(), query, QueryOption_OplogReplay);
invariant(!lastOpConfirm.isEmpty());
OpTime lastOpConfirmTime = fassertStatusOK(40421, OpTime::parseFromOplogEntry(lastOpConfirm));