summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mir <ali.mir@mongodb.com>2020-08-27 14:07:45 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-09 23:29:23 +0000
commit2b5dc35f019a3606c2dfa845cdfb320ffbac8014 (patch)
tree0b7c0bd55ba7b745986e7a248835fcfca1316109
parentee106b978c7466bdd325cfb9f3f029d3769b1c1b (diff)
downloadmongo-2b5dc35f019a3606c2dfa845cdfb320ffbac8014.tar.gz
SERVER-50581 Replace setSlaveOk and getSlaveOk occurrences in jstests
-rw-r--r--jstests/auth/repl.js16
-rw-r--r--jstests/concurrency/fsm_workloads/auth_privilege_consistency.js2
-rw-r--r--jstests/core/shell1.js20
-rw-r--r--jstests/hooks/validate_collections.js2
-rw-r--r--jstests/libs/kill_sessions.js6
-rw-r--r--jstests/libs/override_methods/validate_collections_on_shutdown.js4
-rw-r--r--jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js2
-rw-r--r--jstests/noPassthrough/change_stream_error_label.js8
-rw-r--r--jstests/noPassthrough/out_merge_on_secondary_killop.js2
-rw-r--r--jstests/noPassthrough/server_transaction_metrics_secondary.js4
-rw-r--r--jstests/noPassthrough/startup_recovery_truncates_oplog_holes_after_primary_crash.js2
-rw-r--r--jstests/noPassthrough/stepdown_query.js6
-rw-r--r--jstests/noPassthrough/timestamp_index_builds.js2
-rw-r--r--jstests/noPassthroughWithMongod/replReads.js6
-rw-r--r--jstests/replsets/auth1.js4
-rw-r--r--jstests/replsets/auth_no_pri.js2
-rw-r--r--jstests/replsets/awaitable_ismaster_fcv_change.js2
-rw-r--r--jstests/replsets/awaitdata_getmore_new_last_committed_optime.js2
-rw-r--r--jstests/replsets/buildindexes.js2
-rw-r--r--jstests/replsets/catchup.js2
-rw-r--r--jstests/replsets/explain_slaveok.js107
-rw-r--r--jstests/replsets/fsync_lock_read_secondaries.js2
-rw-r--r--jstests/replsets/groupAndMapReduce.js4
-rw-r--r--jstests/replsets/initial_sync4.js2
-rw-r--r--jstests/replsets/initial_sync_ambiguous_index.js2
-rw-r--r--jstests/replsets/initial_sync_applier_error.js2
-rw-r--r--jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js2
-rw-r--r--jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js2
-rw-r--r--jstests/replsets/initial_sync_invalid_views.js2
-rw-r--r--jstests/replsets/initial_sync_move_forward.js2
-rw-r--r--jstests/replsets/initial_sync_oplog_rollover.js2
-rw-r--r--jstests/replsets/initial_sync_replSetGetStatus.js2
-rw-r--r--jstests/replsets/initial_sync_replicates_prepare_received_during_another_initial_sync.js2
-rw-r--r--jstests/replsets/initial_sync_test_fixture_test.js2
-rw-r--r--jstests/replsets/initial_sync_uuid_not_found.js2
-rw-r--r--jstests/replsets/initial_sync_with_write_load.js4
-rw-r--r--jstests/replsets/kill_reads_with_prepare_conflicts_during_step_up.js2
-rw-r--r--jstests/replsets/libs/initial_sync_update_missing_doc.js2
-rw-r--r--jstests/replsets/libs/secondary_reads_test.js4
-rw-r--r--jstests/replsets/maintenance2.js2
-rw-r--r--jstests/replsets/plan_cache_slaveok.js12
-rw-r--r--jstests/replsets/prepare_transaction_read_at_cluster_time.js2
-rw-r--r--jstests/replsets/quiesce_mode.js2
-rw-r--r--jstests/replsets/read_committed_after_rollback.js2
-rw-r--r--jstests/replsets/read_committed_no_snapshots.js4
-rw-r--r--jstests/replsets/read_operations_during_rollback.js2
-rw-r--r--jstests/replsets/read_operations_during_step_up.js4
-rw-r--r--jstests/replsets/reconstruct_prepared_transactions_initial_sync.js2
-rw-r--r--jstests/replsets/reconstruct_prepared_transactions_initial_sync_index_build.js2
-rw-r--r--jstests/replsets/reconstruct_prepared_transactions_initial_sync_no_oplog_application.js2
-rw-r--r--jstests/replsets/reconstruct_prepared_transactions_initial_sync_on_oplog_seed.js2
-rw-r--r--jstests/replsets/recover_prepared_transactions_startup_secondary_application.js2
-rw-r--r--jstests/replsets/rename_collection_temp.js2
-rw-r--r--jstests/replsets/replset1.js4
-rw-r--r--jstests/replsets/replset2.js2
-rw-r--r--jstests/replsets/replset5.js4
-rw-r--r--jstests/replsets/replset6.js2
-rw-r--r--jstests/replsets/resync_majority_member.js4
-rw-r--r--jstests/replsets/rollback_auth.js4
-rw-r--r--jstests/replsets/rollback_creates_rollback_directory.js4
-rw-r--r--jstests/replsets/rollback_crud_op_sequences.js4
-rw-r--r--jstests/replsets/rollback_ddl_op_sequences.js4
-rw-r--r--jstests/replsets/rslib.js4
-rw-r--r--jstests/replsets/server8070.js4
-rw-r--r--jstests/replsets/slavedelay3.js2
-rw-r--r--jstests/replsets/slaveok_read_pref.js20
-rw-r--r--jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js2
-rw-r--r--jstests/replsets/step_down_on_secondary.js2
-rw-r--r--jstests/replsets/transactions_only_allowed_on_primaries.js4
-rw-r--r--jstests/sharding/agg_mongos_slaveok.js6
-rw-r--r--jstests/sharding/all_shard_and_config_hosts_brought_down_one_by_one.js2
-rw-r--r--jstests/sharding/auth_repl.js12
-rw-r--r--jstests/sharding/auth_slaveok_routing.js8
-rw-r--r--jstests/sharding/autodiscover_config_rs_from_secondary.js2
-rw-r--r--jstests/sharding/balance_repl.js2
-rw-r--r--jstests/sharding/cluster_create_indexes_always_routes_through_primary.js4
-rw-r--r--jstests/sharding/config_rs_no_primary.js4
-rw-r--r--jstests/sharding/count_config_servers.js2
-rw-r--r--jstests/sharding/count_slaveok.js14
-rw-r--r--jstests/sharding/error_propagation.js2
-rw-r--r--jstests/sharding/mongos_rs_auth_shard_failure_tolerance.js28
-rw-r--r--jstests/sharding/mongos_rs_shard_failure_tolerance.js46
-rw-r--r--jstests/sharding/query/explain_read_pref.js2
-rw-r--r--jstests/sharding/read_pref.js2
-rw-r--r--jstests/sharding/read_pref_cmd.js4
-rw-r--r--jstests/sharding/recovering_slaveok.js16
-rw-r--r--jstests/sharding/session_info_in_oplog.js4
-rw-r--r--jstests/sharding/shard_aware_init_secondaries.js4
-rw-r--r--jstests/sharding/shard_identity_config_update.js4
-rw-r--r--jstests/sharding/shard_identity_rollback.js4
-rw-r--r--jstests/sharding/shard_insert_getlasterror_w2.js2
-rw-r--r--jstests/slow1/replsets_priority1.js4
-rw-r--r--jstests/ssl/mongo_uri_secondaries.js2
-rw-r--r--src/mongo/shell/collection.js4
-rw-r--r--src/mongo/shell/db.js6
-rw-r--r--src/mongo/shell/mongo.js4
96 files changed, 275 insertions, 276 deletions
diff --git a/jstests/auth/repl.js b/jstests/auth/repl.js
index 06aa38a38a7..6f5b7ed0dcb 100644
--- a/jstests/auth/repl.js
+++ b/jstests/auth/repl.js
@@ -1,4 +1,4 @@
-// Test that authorization information gets propogated correctly to secondaries and slaves.
+// Test that authorization information gets propogated correctly to secondaries.
var baseName = "jstests_auth_repl";
var rsName = baseName + "_rs";
@@ -26,7 +26,7 @@ var AuthReplTest = function(spec) {
assert(adminPri.auth("super", "super"), "could not authenticate as superuser");
if (secondaryConn != null) {
- secondaryConn.setSlaveOk(true);
+ secondaryConn.setSecondaryOk();
adminSec = secondaryConn.getDB("admin");
}
@@ -38,7 +38,7 @@ var AuthReplTest = function(spec) {
/**
* Use the rolesInfo command to check that the test
- * role is as expected on the secondary/slave
+ * role is as expected on the secondary
*/
var confirmRolesInfo = function(actionType) {
var role = adminSec.getRole(testRole, {showPrivileges: true});
@@ -48,7 +48,7 @@ var AuthReplTest = function(spec) {
/**
* Use the usersInfo command to check that the test
- * user is as expected on the secondary/slave
+ * user is as expected on the secondary
*/
var confirmUsersInfo = function(roleName) {
var user = adminSec.getUser(testUser);
@@ -58,7 +58,7 @@ var AuthReplTest = function(spec) {
/**
* Ensure that the test user has the proper privileges
- * on the secondary/slave
+ * on the secondary
*/
var confirmPrivilegeBeforeUpdate = function() {
// can run hostInfo
@@ -87,7 +87,7 @@ var AuthReplTest = function(spec) {
/**
* Ensure that the auth changes have taken effect
- * properly on the secondary/slave
+ * properly on the secondary
*/
var confirmPrivilegeAfterUpdate = function() {
// cannot run hostInfo
@@ -117,7 +117,7 @@ var AuthReplTest = function(spec) {
*/
that.setSecondary = function(secondary) {
secondaryConn = secondary;
- secondaryConn.setSlaveOk(true);
+ secondaryConn.setSecondaryOk();
adminSec = secondaryConn.getDB("admin");
};
@@ -149,7 +149,7 @@ var AuthReplTest = function(spec) {
/**
* Top-level test for updating users and roles and ensuring that the update
- * has the correct effect on the secondary/slave
+ * has the correct effect on the secondary
*/
that.testAll = function() {
authOnSecondary();
diff --git a/jstests/concurrency/fsm_workloads/auth_privilege_consistency.js b/jstests/concurrency/fsm_workloads/auth_privilege_consistency.js
index 054f0c5ca15..f1c6ad28b9b 100644
--- a/jstests/concurrency/fsm_workloads/auth_privilege_consistency.js
+++ b/jstests/concurrency/fsm_workloads/auth_privilege_consistency.js
@@ -72,7 +72,7 @@ var $config = (function() {
// Create a new connection to any node which isn't "me".
const conn = new Mongo(node);
assert(conn);
- conn.setSlaveOk();
+ conn.setSecondaryOk();
RSnodes.push(conn);
});
diff --git a/jstests/core/shell1.js b/jstests/core/shell1.js
index 7ea23f8d3a5..4fc4c3a1c15 100644
--- a/jstests/core/shell1.js
+++ b/jstests/core/shell1.js
@@ -4,11 +4,15 @@ shellHelper("show", "tables;");
shellHelper("show", "tables");
shellHelper("show", "tables ;");
-// test slaveOk levels
-assert(!db.getSlaveOk() && !db.test.getSlaveOk() && !db.getMongo().getSlaveOk(), "slaveOk 1");
-db.getMongo().setSlaveOk();
-assert(db.getSlaveOk() && db.test.getSlaveOk() && db.getMongo().getSlaveOk(), "slaveOk 2");
-db.setSlaveOk(false);
-assert(!db.getSlaveOk() && !db.test.getSlaveOk() && db.getMongo().getSlaveOk(), "slaveOk 3");
-db.test.setSlaveOk(true);
-assert(!db.getSlaveOk() && db.test.getSlaveOk() && db.getMongo().getSlaveOk(), "slaveOk 4");
+// test secondaryOk levels
+assert(!db.getSecondaryOk() && !db.test.getSecondaryOk() && !db.getMongo().getSecondaryOk(),
+ "secondaryOk 1");
+db.getMongo().setSecondaryOk();
+assert(db.getSecondaryOk() && db.test.getSecondaryOk() && db.getMongo().getSecondaryOk(),
+ "secondaryOk 2");
+db.setSecondaryOk(false);
+assert(!db.getSecondaryOk() && !db.test.getSecondaryOk() && db.getMongo().getSecondaryOk(),
+ "secondaryOk 3");
+db.test.setSecondaryOk();
+assert(!db.getSecondaryOk() && db.test.getSecondaryOk() && db.getMongo().getSecondaryOk(),
+ "secondaryOk 4");
diff --git a/jstests/hooks/validate_collections.js b/jstests/hooks/validate_collections.js
index cf7f1be9707..856191ca51c 100644
--- a/jstests/hooks/validate_collections.js
+++ b/jstests/hooks/validate_collections.js
@@ -88,7 +88,7 @@ function CollectionValidator() {
try {
print('Running validate() on ' + host);
const conn = new Mongo(host);
- conn.setSlaveOk();
+ conn.setSecondaryOk();
jsTest.authenticate(conn);
// Skip validating collections for arbiters.
diff --git a/jstests/libs/kill_sessions.js b/jstests/libs/kill_sessions.js
index b4643ec8ed5..1dabe9c9cea 100644
--- a/jstests/libs/kill_sessions.js
+++ b/jstests/libs/kill_sessions.js
@@ -120,7 +120,7 @@ var _kill_sessions_api_module = (function() {
// hosts. We identify particular ops by secs sleeping.
this.visit(function(client) {
let admin = client.getDB("admin");
- admin.getMongo().setSlaveOk();
+ admin.getMongo().setSecondaryOk();
assert.soon(function() {
let inProgressOps = admin.aggregate([{$currentOp: {'allUsers': true}}]);
@@ -183,7 +183,7 @@ var _kill_sessions_api_module = (function() {
Fixture.prototype.assertNoSessionsInCursors = function() {
this.visit(function(client) {
var db = client.getDB("admin");
- db.setSlaveOk();
+ db.setSecondaryOk();
assert.soon(() => {
let cursors = db.aggregate([
{"$currentOp": {"idleCursors": true, "allUsers": true}}
@@ -205,7 +205,7 @@ var _kill_sessions_api_module = (function() {
});
var db = client.getDB("admin");
- db.setSlaveOk();
+ db.setSecondaryOk();
var cursors = db.aggregate([
{"$currentOp": {"idleCursors": true, "allUsers": true}},
{"$match": {type: "idleCursor"}}
diff --git a/jstests/libs/override_methods/validate_collections_on_shutdown.js b/jstests/libs/override_methods/validate_collections_on_shutdown.js
index a1e56fd1ca8..a378d6e390a 100644
--- a/jstests/libs/override_methods/validate_collections_on_shutdown.js
+++ b/jstests/libs/override_methods/validate_collections_on_shutdown.js
@@ -29,8 +29,8 @@ MongoRunner.validateCollectionsCallback = function(port) {
return;
}
- // Set slaveOk=true so that we can run commands against any secondaries.
- conn.setSlaveOk();
+ // Set secondaryOk=true so that we can run commands against any secondaries.
+ conn.setSecondaryOk();
let dbNames;
let result =
diff --git a/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js b/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js
index 3e855455985..e6191f97449 100644
--- a/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js
+++ b/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js
@@ -29,7 +29,7 @@ assert.commandWorked(secondary.getDB("admin").runCommand(
{configureFailPoint: "waitInFindBeforeMakingBatch", mode: "alwaysOn"}));
const findWait = startParallelShell(function() {
- db.getMongo().setSlaveOk();
+ db.getMongo().setSecondaryOk();
assert.eq(
db.getSiblingDB('read').getCollection('readColl').find().comment('read hangs').itcount(),
1);
diff --git a/jstests/noPassthrough/change_stream_error_label.js b/jstests/noPassthrough/change_stream_error_label.js
index 899207b3bd1..2b326a22cd7 100644
--- a/jstests/noPassthrough/change_stream_error_label.js
+++ b/jstests/noPassthrough/change_stream_error_label.js
@@ -12,9 +12,9 @@ rst.startSet();
rst.initiate();
rst.awaitSecondaryNodes();
-// Disable "slaveOk" on the connection so that we are not allowed to run on the Secondary.
+// Disable "secondaryOk" on the connection so that we are not allowed to run on the Secondary.
const testDB = rst.getSecondary().getDB(jsTestName());
-testDB.getMongo().setSlaveOk(false);
+testDB.getMongo().setSecondaryOk(false);
const coll = testDB.test;
// Issue a change stream. We should fail with a NotPrimaryNoSecondaryOk error.
@@ -28,8 +28,8 @@ assert.contains("ResumableChangeStreamError", err.errorLabels, err);
// Now verify that the 'failGetMoreAfterCursorCheckout' failpoint can effectively exercise the
// error label generation logic for change stream getMores.
function testFailGetMoreAfterCursorCheckoutFailpoint({errorCode, expectedLabel}) {
- // Re-enable "slaveOk" on the test connection.
- testDB.getMongo().setSlaveOk(true);
+ // Re-enable "secondaryOk" on the test connection.
+ testDB.getMongo().setSecondaryOk();
// Activate the failpoint and set the exception that it will throw.
assert.commandWorked(testDB.adminCommand({
diff --git a/jstests/noPassthrough/out_merge_on_secondary_killop.js b/jstests/noPassthrough/out_merge_on_secondary_killop.js
index 7cdc25d8eae..d5863374f96 100644
--- a/jstests/noPassthrough/out_merge_on_secondary_killop.js
+++ b/jstests/noPassthrough/out_merge_on_secondary_killop.js
@@ -57,7 +57,7 @@ function testKillOp(pipeline, comment, failpointName) {
// Run the aggregate and ensure that it is interrupted.
const runAggregate = `
const testDB = db.getSiblingDB("${kDBName}");
- testDB.setSlaveOk(true);
+ testDB.setSecondaryOk();
const res = testDB.runCommand({
aggregate: "inputColl",
pipeline: ${tojson(pipeline)},
diff --git a/jstests/noPassthrough/server_transaction_metrics_secondary.js b/jstests/noPassthrough/server_transaction_metrics_secondary.js
index 9282b19bea0..3a337e17fde 100644
--- a/jstests/noPassthrough/server_transaction_metrics_secondary.js
+++ b/jstests/noPassthrough/server_transaction_metrics_secondary.js
@@ -19,8 +19,8 @@ replTest.initiate(config);
const primary = replTest.getPrimary();
const secondary = replTest.getSecondary();
-// Set slaveOk=true so that normal read commands would be allowed on the secondary.
-secondary.setSlaveOk(true);
+// Set secondaryOk=true so that normal read commands would be allowed on the secondary.
+secondary.setSecondaryOk();
// Create a test collection that we can run commands against.
assert.commandWorked(primary.getDB(dbName)[collName].insert({_id: 0}));
diff --git a/jstests/noPassthrough/startup_recovery_truncates_oplog_holes_after_primary_crash.js b/jstests/noPassthrough/startup_recovery_truncates_oplog_holes_after_primary_crash.js
index 3a43603e935..a00cabc89a9 100644
--- a/jstests/noPassthrough/startup_recovery_truncates_oplog_holes_after_primary_crash.js
+++ b/jstests/noPassthrough/startup_recovery_truncates_oplog_holes_after_primary_crash.js
@@ -87,7 +87,7 @@ assert.soonNoExcept(function() {
});
// Confirm that the write with the oplog hold behind it is now gone (truncated) as expected.
-primary.setSlaveOk();
+primary.setSecondaryOk();
const find = primary.getDB(dbName).getCollection(collName).findOne({_id: "writeAfterHole"});
assert.eq(find, null);
diff --git a/jstests/noPassthrough/stepdown_query.js b/jstests/noPassthrough/stepdown_query.js
index 4809e471f7a..239497725ff 100644
--- a/jstests/noPassthrough/stepdown_query.js
+++ b/jstests/noPassthrough/stepdown_query.js
@@ -25,8 +25,8 @@ var collName = jsTest.name();
function runTest(host, rst, waitForPrimary) {
// We create a new connection to 'host' here instead of passing in the original connection.
- // This to work around the fact that connections created by ReplSetTest already have slaveOk
- // set on them, but we need a connection with slaveOk not set for this test.
+ // This to work around the fact that connections created by ReplSetTest already have secondaryOk
+ // set on them, but we need a connection with secondaryOk not set for this test.
var conn = new Mongo(host);
var coll = conn.getDB(dbName).getCollection(collName);
assert(!coll.exists());
@@ -51,7 +51,7 @@ function runTest(host, rst, waitForPrimary) {
} catch (e) {
}
- // Even though our connection doesn't have slaveOk set, we should still be able to iterate
+ // Even though our connection doesn't have secondaryOk set, we should still be able to iterate
// our cursor and kill our cursor.
assert(cursor.hasNext());
assert.doesNotThrow(function() {
diff --git a/jstests/noPassthrough/timestamp_index_builds.js b/jstests/noPassthrough/timestamp_index_builds.js
index 8e13ff0d21c..f7995108f34 100644
--- a/jstests/noPassthrough/timestamp_index_builds.js
+++ b/jstests/noPassthrough/timestamp_index_builds.js
@@ -87,7 +87,7 @@ for (let nodeIdx = 0; nodeIdx < 2; ++nodeIdx) {
jsTestLog("Starting as a replica set. Both indexes should exist. Node: " + nodeIdentity);
let conn = rst.start(nodeIdx, {startClean: false}, true);
rst.waitForState(conn, ReplSetTest.State.SECONDARY);
- conn.setSlaveOk();
+ conn.setSecondaryOk();
IndexBuildTest.assertIndexes(getColl(conn), 2, ['_id_', 'foo_1']);
rst.stop(nodeIdx);
}
diff --git a/jstests/noPassthroughWithMongod/replReads.js b/jstests/noPassthroughWithMongod/replReads.js
index 5c40dbd900c..fde1143911c 100644
--- a/jstests/noPassthroughWithMongod/replReads.js
+++ b/jstests/noPassthroughWithMongod/replReads.js
@@ -1,4 +1,4 @@
-// Test that doing slaveOk reads from secondaries hits all the secondaries evenly
+// Test that doing secondaryOk reads from secondaries hits all the secondaries evenly
// @tags: [requires_sharding]
function testReadLoadBalancing(numReplicas) {
@@ -52,7 +52,7 @@ function testReadLoadBalancing(numReplicas) {
for (var i = 0; i < secondaries.length * 10; i++) {
conn = new Mongo(s._mongos[0].host);
- conn.setSlaveOk();
+ conn.setSecondaryOk();
conn.getDB('test').foo.findOne();
connections.push(conn);
}
@@ -103,7 +103,7 @@ function testReadLoadBalancing(numReplicas) {
for (var i = 0; i < secondaries.length * 10; i++) {
conn = new Mongo(s._mongos[0].host);
- conn.setSlaveOk();
+ conn.setSecondaryOk();
conn.getDB('test').foo.findOne();
connections.push(conn);
}
diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js
index cfc9c405dd1..a91137391a8 100644
--- a/jstests/replsets/auth1.js
+++ b/jstests/replsets/auth1.js
@@ -88,7 +88,7 @@ print("try some legal and illegal reads");
var r = primary.getDB("test").foo.findOne();
assert.eq(r.x, 1);
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
function doQueryOn(p) {
var error = assert.throws(function() {
@@ -200,7 +200,7 @@ wait(function() {
print("make sure it has the config, too");
assert.soon(function() {
for (var i in rs.nodes) {
- rs.nodes[i].setSlaveOk();
+ rs.nodes[i].setSecondaryOk();
rs.nodes[i].getDB("admin").auth("foo", "bar");
config = rs.nodes[i].getDB("local").system.replset.findOne();
// We expect the config version to be 3 due to the initial config and then the
diff --git a/jstests/replsets/auth_no_pri.js b/jstests/replsets/auth_no_pri.js
index 16a94763b04..bc606dc913a 100644
--- a/jstests/replsets/auth_no_pri.js
+++ b/jstests/replsets/auth_no_pri.js
@@ -23,7 +23,7 @@ rs.waitForState(nodes[2], ReplSetTest.State.SECONDARY);
// Make sure you can still authenticate a replset connection with no primary
var conn2 = new Mongo(rs.getURL());
-conn2.setSlaveOk(true);
+conn2.setSecondaryOk();
assert(conn2.getDB('admin').auth({user: 'admin', pwd: 'pwd', mechanism: "SCRAM-SHA-1"}));
assert.eq(1, conn2.getDB('admin').foo.findOne().a);
diff --git a/jstests/replsets/awaitable_ismaster_fcv_change.js b/jstests/replsets/awaitable_ismaster_fcv_change.js
index 41ed644e5e6..9e22fde507d 100644
--- a/jstests/replsets/awaitable_ismaster_fcv_change.js
+++ b/jstests/replsets/awaitable_ismaster_fcv_change.js
@@ -21,7 +21,7 @@ const secondaryAdminDB = secondary.getDB("admin");
function runAwaitableIsMasterBeforeFCVChange(
topologyVersionField, targetFCV, isPrimary, prevMinWireVersion, serverMaxWireVersion) {
- db.getMongo().setSlaveOk();
+ db.getMongo().setSecondaryOk();
let response = assert.commandWorked(db.runCommand({
isMaster: 1,
topologyVersion: topologyVersionField,
diff --git a/jstests/replsets/awaitdata_getmore_new_last_committed_optime.js b/jstests/replsets/awaitdata_getmore_new_last_committed_optime.js
index f98e2fb4326..4d17389c209 100644
--- a/jstests/replsets/awaitdata_getmore_new_last_committed_optime.js
+++ b/jstests/replsets/awaitdata_getmore_new_last_committed_optime.js
@@ -56,7 +56,7 @@ let waitForGetMoreToFinish = startParallelShell(() => {
load('jstests/replsets/rslib.js');
const secondary = db.getMongo();
- secondary.setSlaveOk();
+ secondary.setSecondaryOk();
const dbName = 'test';
const collName = 'coll';
diff --git a/jstests/replsets/buildindexes.js b/jstests/replsets/buildindexes.js
index e00a9e94ef7..3be0ba68896 100644
--- a/jstests/replsets/buildindexes.js
+++ b/jstests/replsets/buildindexes.js
@@ -21,7 +21,7 @@ var primary = replTest.getPrimary().getDB(name);
var secondaryConns = replTest.getSecondaries();
var secondaries = [];
for (var i in secondaryConns) {
- secondaryConns[i].setSlaveOk();
+ secondaryConns[i].setSecondaryOk();
secondaries.push(secondaryConns[i].getDB(name));
}
replTest.awaitReplication();
diff --git a/jstests/replsets/catchup.js b/jstests/replsets/catchup.js
index a8284ad1772..7ab31e4d76c 100644
--- a/jstests/replsets/catchup.js
+++ b/jstests/replsets/catchup.js
@@ -37,7 +37,7 @@ rst.nodes.forEach(function(node) {
});
function checkOpInOplog(node, op, count) {
- node.getDB("admin").getMongo().setSlaveOk();
+ node.getDB("admin").getMongo().setSecondaryOk();
var oplog = node.getDB("local")['oplog.rs'];
var oplogArray = oplog.find().toArray();
assert.eq(oplog.count(op), count, "op: " + tojson(op) + ", oplog: " + tojson(oplogArray));
diff --git a/jstests/replsets/explain_slaveok.js b/jstests/replsets/explain_slaveok.js
index 68eda89bce7..f3215af9ab6 100644
--- a/jstests/replsets/explain_slaveok.js
+++ b/jstests/replsets/explain_slaveok.js
@@ -1,12 +1,12 @@
// Test the explain command on the primary and on secondaries:
//
-// 1) Explain of read operations should work on the secondaries iff slaveOk is set.
+// 1) Explain of read operations should work on the secondaries iff secondaryOk is set.
//
// 2) Explain of write operations should
-// --fail on secondaries, even if slaveOk is set,
+// --fail on secondaries, even if secondaryOk is set,
// --succeed on primary without applying any writes.
-var name = "explain_slaveok";
+var name = "explain_secondaryok";
print("Start replica set with two nodes");
var replTest = new ReplSetTest({name: name, nodes: 2});
@@ -16,22 +16,22 @@ var primary = replTest.getPrimary();
// Insert a document and let it sync to the secondary.
print("Initial sync");
-primary.getDB("test").explain_slaveok.insert({a: 1});
+primary.getDB("test").explain_secondaryok.insert({a: 1});
replTest.awaitReplication();
// Check that the document is present on the primary.
-assert.eq(1, primary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
+assert.eq(1, primary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
-// We shouldn't be able to read from the secondary with slaveOk off.
+// We shouldn't be able to read from the secondary with secondaryOk off.
var secondary = replTest.getSecondary();
-secondary.getDB("test").getMongo().setSlaveOk(false);
+secondary.getDB("test").getMongo().setSecondaryOk(false);
assert.throws(function() {
- secondary.getDB("test").explain_slaveok.findOne({a: 1});
+ secondary.getDB("test").explain_secondaryok.findOne({a: 1});
});
-// With slaveOk on, we should be able to read from the secondary.
-secondary.getDB("test").getMongo().setSlaveOk(true);
-assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
+// With secondaryOk on, we should be able to read from the secondary.
+secondary.getDB("test").getMongo().setSecondaryOk();
+assert.eq(1, secondary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
//
// Test explains on primary.
@@ -39,12 +39,12 @@ assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
// Explain a count on the primary.
var explainOut = primary.getDB("test").runCommand(
- {explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
+ {explain: {count: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
assert.commandWorked(explainOut, "explain read op on primary");
// Explain an update on the primary.
explainOut = primary.getDB("test").runCommand({
- explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
+ explain: {update: "explain_secondaryok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
verbosity: "executionStats"
});
assert.commandWorked(explainOut, "explain write op on primary");
@@ -57,52 +57,52 @@ assert.eq(1, stages.nWouldModify);
// Confirm that the document did not actually get modified on the primary
// or on the secondary.
-assert.eq(1, primary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
-secondary.getDB("test").getMongo().setSlaveOk(true);
-assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
+assert.eq(1, primary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
+secondary.getDB("test").getMongo().setSecondaryOk();
+assert.eq(1, secondary.getDB("test").explain_secondaryok.findOne({a: 1})["a"]);
//
// Test explains on secondary.
//
-// Explain a count on the secondary with slaveOk off. Should fail because
-// slaveOk is required for explains on a secondary.
-secondary.getDB("test").getMongo().setSlaveOk(false);
+// Explain a count on the secondary with secondaryOk off. Should fail because
+// secondaryOk is required for explains on a secondary.
+secondary.getDB("test").getMongo().setSecondaryOk(false);
explainOut = secondary.getDB("test").runCommand(
- {explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
-assert.commandFailed(explainOut, "explain read op on secondary, slaveOk false");
+ {explain: {count: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
+assert.commandFailed(explainOut, "explain read op on secondary, secondaryOk false");
-// Explain of count should succeed once slaveOk is true.
-secondary.getDB("test").getMongo().setSlaveOk(true);
+// Explain of count should succeed once secondaryOk is true.
+secondary.getDB("test").getMongo().setSecondaryOk();
explainOut = secondary.getDB("test").runCommand(
- {explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
-assert.commandWorked(explainOut, "explain read op on secondary, slaveOk true");
+ {explain: {count: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
+assert.commandWorked(explainOut, "explain read op on secondary, secondaryOk true");
-// Explain .find() on a secondary, setting slaveOk directly on the query.
-secondary.getDB("test").getMongo().setSlaveOk(false);
+// Explain .find() on a secondary, setting secondaryOk directly on the query.
+secondary.getDB("test").getMongo().setSecondaryOk(false);
assert.throws(function() {
- secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
+ secondary.getDB("test").explain_secondaryok.explain("executionStats").find({a: 1}).finish();
});
-secondary.getDB("test").getMongo().setSlaveOk(false);
+secondary.getDB("test").getMongo().setSecondaryOk(false);
explainOut = secondary.getDB("test")
- .explain_slaveok.explain("executionStats")
+ .explain_secondaryok.explain("executionStats")
.find({a: 1})
.addOption(DBQuery.Option.slaveOk)
.finish();
-assert.commandWorked(explainOut, "explain read op on secondary, slaveOk set to true on query");
+assert.commandWorked(explainOut, "explain read op on secondary, slaveOk bit set to true on query");
-secondary.getDB("test").getMongo().setSlaveOk(true);
+secondary.getDB("test").getMongo().setSecondaryOk();
explainOut =
- secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
-assert.commandWorked(explainOut, "explain .find() on secondary, slaveOk set to true");
+ secondary.getDB("test").explain_secondaryok.explain("executionStats").find({a: 1}).finish();
+assert.commandWorked(explainOut, "explain .find() on secondary, secondaryOk set to true");
-// Explain .find() on a secondary, setting slaveOk to false with various read preferences.
+// Explain .find() on a secondary, setting secondaryOk to false with various read preferences.
var readPrefModes = ["secondary", "secondaryPreferred", "primaryPreferred", "nearest"];
readPrefModes.forEach(function(prefString) {
- secondary.getDB("test").getMongo().setSlaveOk(false);
+ secondary.getDB("test").getMongo().setSecondaryOk(false);
explainOut = secondary.getDB("test")
- .explain_slaveok.explain("executionStats")
+ .explain_secondaryok.explain("executionStats")
.find({a: 1})
.readPref(prefString)
.finish();
@@ -112,7 +112,7 @@ readPrefModes.forEach(function(prefString) {
// Similarly should succeed if a read preference is set on the connection.
secondary.setReadPref(prefString);
explainOut =
- secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
+ secondary.getDB("test").explain_secondaryok.explain("executionStats").find({a: 1}).finish();
assert.commandWorked(
explainOut,
"explain .find() on secondary, '" + prefString + "' read preference on connection");
@@ -120,35 +120,36 @@ readPrefModes.forEach(function(prefString) {
secondary.setReadPref();
});
-// Fail explain find() on a secondary, setting slaveOk to false with read preference set to primary.
+// Fail explain find() on a secondary, setting secondaryOk to false with read preference set to
+// primary.
var prefStringPrimary = "primary";
-secondary.getDB("test").getMongo().setSlaveOk(false);
+secondary.getDB("test").getMongo().setSecondaryOk(false);
explainOut = secondary.getDB("test").runCommand(
- {explain: {find: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
-assert.commandFailed(explainOut, "not master and slaveOk=false");
+ {explain: {find: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
+assert.commandFailed(explainOut, "not primary and secondaryOk=false");
// Similarly should fail if a read preference is set on the connection.
secondary.setReadPref(prefStringPrimary);
explainOut = secondary.getDB("test").runCommand(
- {explain: {find: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
-assert.commandFailed(explainOut, "not master and slaveOk=false");
+ {explain: {find: "explain_secondaryok", query: {a: 1}}, verbosity: "executionStats"});
+assert.commandFailed(explainOut, "not primary and secondaryOk=false");
// Unset read pref on the connection.
secondary.setReadPref();
-// Explain an update on the secondary with slaveOk off. Should fail because
-// slaveOk is required for explains on a secondary.
-secondary.getDB("test").getMongo().setSlaveOk(false);
+// Explain an update on the secondary with secondaryOk off. Should fail because
+// secondaryOk is required for explains on a secondary.
+secondary.getDB("test").getMongo().setSecondaryOk(false);
explainOut = secondary.getDB("test").runCommand({
- explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
+ explain: {update: "explain_secondaryok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
verbosity: "executionStats"
});
-assert.commandFailed(explainOut, "explain write op on secondary, slaveOk false");
+assert.commandFailed(explainOut, "explain write op on secondary, secondaryOk false");
-// Explain of the update should also fail with slaveOk on.
-secondary.getDB("test").getMongo().setSlaveOk(true);
+// Explain of the update should also fail with secondaryOk on.
+secondary.getDB("test").getMongo().setSecondaryOk();
explainOut = secondary.getDB("test").runCommand({
- explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
+ explain: {update: "explain_secondaryok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
verbosity: "executionStats"
});
-assert.commandFailed(explainOut, "explain write op on secondary, slaveOk true");
+assert.commandFailed(explainOut, "explain write op on secondary, secondaryOk true");
replTest.stopSet();
diff --git a/jstests/replsets/fsync_lock_read_secondaries.js b/jstests/replsets/fsync_lock_read_secondaries.js
index e73ceab58ba..daed9de7ad6 100644
--- a/jstests/replsets/fsync_lock_read_secondaries.js
+++ b/jstests/replsets/fsync_lock_read_secondaries.js
@@ -50,7 +50,7 @@ replTest.awaitReplication();
// Calling getPrimary also populates '_secondaries'.
var secondaries = replTest.getSecondaries();
-secondaries[0].setSlaveOk();
+secondaries[0].setSecondaryOk();
assert.commandWorked(secondaries[0].getDB("admin").runCommand({fsync: 1, lock: 1}));
var docNum = 1000;
diff --git a/jstests/replsets/groupAndMapReduce.js b/jstests/replsets/groupAndMapReduce.js
index 270436bf62c..2723f800a07 100644
--- a/jstests/replsets/groupAndMapReduce.js
+++ b/jstests/replsets/groupAndMapReduce.js
@@ -36,7 +36,7 @@ doTest = function(signal) {
assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
secondaries.forEach(function(secondary) {
// try to read from secondary
- secondary.slaveOk = true;
+ secondary.setSecondaryOk();
var count = secondary.getDB("foo").foo.find().itcount();
printjson(count);
assert.eq(len, count, "secondary count wrong: " + secondary);
@@ -46,7 +46,7 @@ doTest = function(signal) {
printjson(one);
print("Calling inline mr() with slaveOk=true, must succeed");
- secondary.slaveOk = true;
+ secondary.setSecondaryOk();
map = function() {
emit(this.a, 1);
};
diff --git a/jstests/replsets/initial_sync4.js b/jstests/replsets/initial_sync4.js
index 80103839bfb..35dbd632715 100644
--- a/jstests/replsets/initial_sync4.js
+++ b/jstests/replsets/initial_sync4.js
@@ -45,7 +45,7 @@
jsTestLog("5. Wait for new node to start cloning");
- s.setSlaveOk();
+ s.setSecondaryOk();
var sc = s.getDB("d")["c"];
wait(function() {
diff --git a/jstests/replsets/initial_sync_ambiguous_index.js b/jstests/replsets/initial_sync_ambiguous_index.js
index 7e415fade43..c50324db935 100644
--- a/jstests/replsets/initial_sync_ambiguous_index.js
+++ b/jstests/replsets/initial_sync_ambiguous_index.js
@@ -44,7 +44,7 @@ const secondary = rst.add({
rsConfig: {votes: 0, priority: 0},
setParameter: {"numInitialSyncAttempts": 1, 'collectionClonerBatchSize': clonerBatchSize}
});
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
const secondaryColl = secondary.getDB(dbName).getCollection(collectionName);
// We set the collectionClonerBatchSize low above, so we will definitely hit
diff --git a/jstests/replsets/initial_sync_applier_error.js b/jstests/replsets/initial_sync_applier_error.js
index 7ef7058aea4..e880c739ef1 100644
--- a/jstests/replsets/initial_sync_applier_error.js
+++ b/jstests/replsets/initial_sync_applier_error.js
@@ -31,7 +31,7 @@ assert.commandWorked(coll.insert({_id: 0, content: "hi"}));
// but before copying databases.
var secondary =
replSet.add({setParameter: "numInitialSyncAttempts=2", rsConfig: {votes: 0, priority: 0}});
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
let failPoint = configureFailPoint(secondary, 'initialSyncHangBeforeCopyingDatabases');
replSet.reInitiate();
diff --git a/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js b/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js
index 023184c5dfb..292b0318ecd 100644
--- a/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js
+++ b/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js
@@ -139,7 +139,7 @@ replTest.awaitReplication();
jsTestLog("Initial sync completed");
// Make sure the secondary fetched enough transaction oplog entries.
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
const secondaryOplog = secondary.getDB("local").getCollection("oplog.rs");
assert.eq(secondaryOplog.find({"ts": beginFetchingTs}).itcount(), 1);
diff --git a/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js b/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
index a4420ff9940..9b1839b4c43 100644
--- a/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
+++ b/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
@@ -98,7 +98,7 @@ replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
jsTestLog("Initial sync completed");
// Make sure the secondary fetched enough transaction oplog entries.
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
const secondaryOplog = secondary.getDB("local").getCollection("oplog.rs");
assert.eq(secondaryOplog.find({"ts": beginFetchingTs}).itcount(), 1);
diff --git a/jstests/replsets/initial_sync_invalid_views.js b/jstests/replsets/initial_sync_invalid_views.js
index fb5a1975323..9faf5207608 100644
--- a/jstests/replsets/initial_sync_invalid_views.js
+++ b/jstests/replsets/initial_sync_invalid_views.js
@@ -18,7 +18,7 @@ assert.commandWorked(coll.insert({a: 1}));
// Add a secondary node but make it hang before copying databases.
let secondary = replSet.add({rsConfig: {votes: 0, priority: 0}});
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
assert.commandWorked(secondary.getDB('admin').runCommand(
{configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'alwaysOn'}));
diff --git a/jstests/replsets/initial_sync_move_forward.js b/jstests/replsets/initial_sync_move_forward.js
index d5142d06b98..c99b529a700 100644
--- a/jstests/replsets/initial_sync_move_forward.js
+++ b/jstests/replsets/initial_sync_move_forward.js
@@ -41,7 +41,7 @@ assert.commandWorked(masterColl.ensureIndex({x: 1}, {unique: true}));
// Add a secondary.
var secondary =
rst.add({setParameter: "numInitialSyncAttempts=1", rsConfig: {votes: 0, priority: 0}});
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
var secondaryColl = secondary.getDB("test").coll;
// Pause initial sync when the secondary has copied {_id: 0, x: 0} and {_id: 1, x: 1}.
diff --git a/jstests/replsets/initial_sync_oplog_rollover.js b/jstests/replsets/initial_sync_oplog_rollover.js
index 268ec261d39..b9c1eda8f2f 100644
--- a/jstests/replsets/initial_sync_oplog_rollover.js
+++ b/jstests/replsets/initial_sync_oplog_rollover.js
@@ -38,7 +38,7 @@ var firstOplogEntry = getFirstOplogEntry(primary);
// Add a secondary node but make it hang before copying databases.
var secondary = replSet.add();
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
var failPoint = configureFailPoint(secondary, 'initialSyncHangBeforeCopyingDatabases');
replSet.reInitiate();
diff --git a/jstests/replsets/initial_sync_replSetGetStatus.js b/jstests/replsets/initial_sync_replSetGetStatus.js
index d315421577a..3d999cc9553 100644
--- a/jstests/replsets/initial_sync_replSetGetStatus.js
+++ b/jstests/replsets/initial_sync_replSetGetStatus.js
@@ -24,7 +24,7 @@ assert.commandWorked(coll.insert({a: 2}));
// Add a secondary node but make it hang before copying databases.
var secondary = replSet.add({rsConfig: {votes: 0, priority: 0}});
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
var failPointBeforeCopying = configureFailPoint(secondary, 'initialSyncHangBeforeCopyingDatabases');
var failPointBeforeFinish = configureFailPoint(secondary, 'initialSyncHangBeforeFinish');
diff --git a/jstests/replsets/initial_sync_replicates_prepare_received_during_another_initial_sync.js b/jstests/replsets/initial_sync_replicates_prepare_received_during_another_initial_sync.js
index 80012cab607..9ea82c52bb3 100644
--- a/jstests/replsets/initial_sync_replicates_prepare_received_during_another_initial_sync.js
+++ b/jstests/replsets/initial_sync_replicates_prepare_received_during_another_initial_sync.js
@@ -47,7 +47,7 @@ function restartSecondaryAndForceSyncSource(replSet, secondary, syncSource, dbNa
// Wait for the secondary to complete initial sync.
waitForState(secondary, ReplSetTest.State.SECONDARY);
// Allow for secondary reads.
- secondary.setSlaveOk();
+ secondary.setSecondaryOk();
const secondaryDB = secondary.getDB(dbName);
// Confirm that we have a prepared transaction in progress on the secondary.
diff --git a/jstests/replsets/initial_sync_test_fixture_test.js b/jstests/replsets/initial_sync_test_fixture_test.js
index 625620584a4..755df7a2109 100644
--- a/jstests/replsets/initial_sync_test_fixture_test.js
+++ b/jstests/replsets/initial_sync_test_fixture_test.js
@@ -108,7 +108,7 @@ let prepareTimestamp = PrepareHelpers.prepareTransaction(session);
assert(!initialSyncTest.step());
secondary = initialSyncTest.getSecondary();
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
// Make sure that we cannot read from this node yet.
assert.commandFailedWithCode(secondary.getDB("test").runCommand({count: "foo"}),
diff --git a/jstests/replsets/initial_sync_uuid_not_found.js b/jstests/replsets/initial_sync_uuid_not_found.js
index 90e0024b76c..2e2911ee6dd 100644
--- a/jstests/replsets/initial_sync_uuid_not_found.js
+++ b/jstests/replsets/initial_sync_uuid_not_found.js
@@ -39,7 +39,7 @@ function ResyncWithFailpoint(failpointName, failpointData) {
assert.eq(primary, rst.getPrimary(), 'Primary changed after reconfig');
jsTestLog('Wait for new node to start cloning');
- secondary.setSlaveOk();
+ secondary.setSecondaryOk();
const secondaryDB = secondary.getDB(primaryDB.getName());
const secondaryColl = secondaryDB[primaryColl.getName()];
diff --git a/jstests/replsets/initial_sync_with_write_load.js b/jstests/replsets/initial_sync_with_write_load.js
index fc1164c6c43..0474c1f9c10 100644
--- a/jstests/replsets/initial_sync_with_write_load.js
+++ b/jstests/replsets/initial_sync_with_write_load.js
@@ -24,8 +24,8 @@ replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
var master = replTest.getPrimary();
var a_conn = conns[0];
var b_conn = conns[1];
-a_conn.setSlaveOk();
-b_conn.setSlaveOk();
+a_conn.setSecondaryOk();
+b_conn.setSecondaryOk();
var A = a_conn.getDB("test");
var B = b_conn.getDB("test");
var AID = replTest.getNodeId(a_conn);
diff --git a/jstests/replsets/kill_reads_with_prepare_conflicts_during_step_up.js b/jstests/replsets/kill_reads_with_prepare_conflicts_during_step_up.js
index 1c71eb94b66..da8c8fd544d 100644
--- a/jstests/replsets/kill_reads_with_prepare_conflicts_during_step_up.js
+++ b/jstests/replsets/kill_reads_with_prepare_conflicts_during_step_up.js
@@ -74,7 +74,7 @@ TestData.clusterTime = clusterTimeAfterPrepare;
const waitForSecondaryReadBlockedOnPrepareConflictThread = startParallelShell(() => {
// Allow for secondary reads.
- db.getMongo().setSlaveOk();
+ db.getMongo().setSecondaryOk();
const parallelTestDB = db.getSiblingDB(TestData.dbName);
const parallelTestCollName = TestData.collName;
diff --git a/jstests/replsets/libs/initial_sync_update_missing_doc.js b/jstests/replsets/libs/initial_sync_update_missing_doc.js
index f45d9a4e107..68bb14ac668 100644
--- a/jstests/replsets/libs/initial_sync_update_missing_doc.js
+++ b/jstests/replsets/libs/initial_sync_update_missing_doc.js
@@ -17,7 +17,7 @@ load("jstests/libs/fail_point_util.js");
// must be called after reInitiateSetWithSecondary.
var reInitiateSetWithSecondary = function(replSet, secondaryConfig) {
const secondary = replSet.add(secondaryConfig);
- secondary.setSlaveOk();
+ secondary.setSecondaryOk();
// Make the secondary hang after retrieving the last op on the sync source but before
// copying databases.
diff --git a/jstests/replsets/libs/secondary_reads_test.js b/jstests/replsets/libs/secondary_reads_test.js
index 1d712fce05a..4840708dba2 100644
--- a/jstests/replsets/libs/secondary_reads_test.js
+++ b/jstests/replsets/libs/secondary_reads_test.js
@@ -14,7 +14,7 @@ function SecondaryReadsTest(name = "secondary_reads_test") {
let primaryDB = primary.getDB(dbName);
let secondary = rst.getSecondary();
let secondaryDB = secondary.getDB(dbName);
- secondaryDB.getMongo().setSlaveOk();
+ secondaryDB.getMongo().setSecondaryOk();
let readers = [];
let signalColl = "signalColl";
@@ -37,7 +37,7 @@ function SecondaryReadsTest(name = "secondary_reads_test") {
this.startSecondaryReaders = function(nReaders, readFn) {
let read = function() {
- db.getMongo().setSlaveOk();
+ db.getMongo().setSecondaryOk();
db = db.getSiblingDB(TestData.dbName);
while (true) {
readFn();
diff --git a/jstests/replsets/maintenance2.js b/jstests/replsets/maintenance2.js
index 2b904346945..c62d6bf17b6 100644
--- a/jstests/replsets/maintenance2.js
+++ b/jstests/replsets/maintenance2.js
@@ -40,7 +40,7 @@ secondaries.forEach(function(secondary) {
assert.eq(stats.myState, 3, "Secondary should be in recovering state.");
print("count should fail in recovering state...");
- secondary.slaveOk = true;
+ secondary.setSecondaryOk();
assert.commandFailed(secondary.getDB("foo").runCommand({count: "foo"}));
// unset maintenance mode when done
diff --git a/jstests/replsets/plan_cache_slaveok.js b/jstests/replsets/plan_cache_slaveok.js
index 4ef60d93795..c20decf9eb1 100644
--- a/jstests/replsets/plan_cache_slaveok.js
+++ b/jstests/replsets/plan_cache_slaveok.js
@@ -1,7 +1,7 @@
// Verify that the plan cache and index filter commands can be run on secondaries, but only
-// if slave ok is explicitly set.
+// if secondaryOk is explicitly set.
-var name = "plan_cache_slaveok";
+var name = "plan_cache_secondaryok";
function assertPlanCacheCommandsSucceed(db) {
assert.commandWorked(db.runCommand({planCacheClear: name, query: {a: 1}}));
@@ -50,13 +50,13 @@ assert.eq(1, primary.getDB("test")[name].findOne({a: 1})["a"]);
// Make sure the plan cache commands succeed on the primary.
assertPlanCacheCommandsSucceed(primary.getDB("test"));
-// With slave ok false, the commands should fail on the secondary.
+// With secondaryOk false, the commands should fail on the secondary.
var secondary = replTest.getSecondary();
-secondary.getDB("test").getMongo().setSlaveOk(false);
+secondary.getDB("test").getMongo().setSecondaryOk(false);
assertPlanCacheCommandsFail(secondary.getDB("test"));
-// With slave ok true, the commands should succeed on the secondary.
-secondary.getDB("test").getMongo().setSlaveOk(true);
+// With secondaryOk true, the commands should succeed on the secondary.
+secondary.getDB("test").getMongo().setSecondaryOk();
assertPlanCacheCommandsSucceed(secondary.getDB("test"));
replTest.stopSet();
diff --git a/jstests/replsets/prepare_transaction_read_at_cluster_time.js b/jstests/replsets/prepare_transaction_read_at_cluster_time.js
index 24894823b1a..1e6ae30b5d6 100644
--- a/jstests/replsets/prepare_transaction_read_at_cluster_time.js
+++ b/jstests/replsets/prepare_transaction_read_at_cluster_time.js
@@ -16,7 +16,7 @@ const runDBHashFn = (host, dbName, clusterTime, useSnapshot) => {
const conn = new Mongo(host);
const db = conn.getDB(dbName);
- conn.setSlaveOk();
+ conn.setSecondaryOk();
let cmd;
if (useSnapshot) {
cmd = {dbHash: 1, readConcern: {level: "snapshot", atClusterTime: eval(clusterTime)}};
diff --git a/jstests/replsets/quiesce_mode.js b/jstests/replsets/quiesce_mode.js
index ae47952cbf8..52c39f3edbd 100644
--- a/jstests/replsets/quiesce_mode.js
+++ b/jstests/replsets/quiesce_mode.js
@@ -48,7 +48,7 @@ function runAwaitableIsMaster(topologyVersionField) {
}
function runFind() {
- db.getMongo().setSlaveOk();
+ db.getMongo().setSecondaryOk();
assert.eq(4, db.getSiblingDB("test").coll.find().itcount());
}
diff --git a/jstests/replsets/read_committed_after_rollback.js b/jstests/replsets/read_committed_after_rollback.js
index 41bd1d29268..a7e46e15e86 100644
--- a/jstests/replsets/read_committed_after_rollback.js
+++ b/jstests/replsets/read_committed_after_rollback.js
@@ -75,7 +75,7 @@ assert.eq(doDirtyRead(oldPrimaryColl), 'INVALID');
assert.eq(doCommittedRead(oldPrimaryColl), 'old');
// Change the partitioning so that oldPrimary is isolated, and newPrimary can be elected.
-oldPrimary.setSlaveOk();
+oldPrimary.setSecondaryOk();
oldPrimary.disconnect(arbiters);
newPrimary.reconnect(arbiters);
assert.soon(() => newPrimary.adminCommand('isMaster').ismaster, '', 60 * 1000);
diff --git a/jstests/replsets/read_committed_no_snapshots.js b/jstests/replsets/read_committed_no_snapshots.js
index a0fe52cd565..280b0de7d49 100644
--- a/jstests/replsets/read_committed_no_snapshots.js
+++ b/jstests/replsets/read_committed_no_snapshots.js
@@ -38,9 +38,9 @@ replTest.initiateWithAnyNodeAsPrimary(
var primary = replTest.getPrimary();
var secondaries = replTest.getSecondaries();
var healthySecondary = secondaries[0];
-healthySecondary.setSlaveOk();
+healthySecondary.setSecondaryOk();
var noSnapshotSecondary = secondaries[1];
-noSnapshotSecondary.setSlaveOk();
+noSnapshotSecondary.setSecondaryOk();
// Do a write, wait for it to replicate, and ensure it is visible.
var res = primary.getDB(name).runCommandWithMetadata( //
diff --git a/jstests/replsets/read_operations_during_rollback.js b/jstests/replsets/read_operations_during_rollback.js
index d743c7b8303..f91ba15d31b 100644
--- a/jstests/replsets/read_operations_during_rollback.js
+++ b/jstests/replsets/read_operations_during_rollback.js
@@ -24,7 +24,7 @@ setFailPoint(rollbackNode, "rollbackHangAfterTransitionToRollback");
setFailPoint(rollbackNode, "GetMoreHangBeforeReadLock");
const joinGetMoreThread = startParallelShell(() => {
- db.getMongo().setSlaveOk();
+ db.getMongo().setSecondaryOk();
const cursorID = assert.commandWorked(db.runCommand({"find": "coll", batchSize: 0})).cursor.id;
// Make sure an outstanding read operation gets killed during rollback even though the read
// was started before rollback. Outstanding read operations are killed during rollback and
diff --git a/jstests/replsets/read_operations_during_step_up.js b/jstests/replsets/read_operations_during_step_up.js
index 91d202659a4..ef666bd4611 100644
--- a/jstests/replsets/read_operations_during_step_up.js
+++ b/jstests/replsets/read_operations_during_step_up.js
@@ -49,7 +49,7 @@ jsTestLog("2. Start blocking getMore cmd before step up");
const joinGetMoreThread = startParallelShell(() => {
// Open another cursor on secondary before step up.
secondaryDB = db.getSiblingDB(TestData.dbName);
- secondaryDB.getMongo().setSlaveOk(true);
+ secondaryDB.getMongo().setSecondaryOk();
const cursorIdToBeReadDuringStepUp =
assert.commandWorked(secondaryDB.runCommand({"find": TestData.collName, batchSize: 0}))
@@ -71,7 +71,7 @@ waitForCurOpByFailPoint(
jsTestLog("2. Start blocking find cmd before step up");
const joinFindThread = startParallelShell(() => {
secondaryDB = db.getSiblingDB(TestData.dbName);
- secondaryDB.getMongo().setSlaveOk(true);
+ secondaryDB.getMongo().setSecondaryOk();
// Enable the fail point for find cmd.
assert.commandWorked(
diff --git a/jstests/replsets/reconstruct_prepared_transactions_initial_sync.js b/jstests/replsets/reconstruct_prepared_transactions_initial_sync.js
index 6257f066eab..b72dd806295 100644
--- a/jstests/replsets/reconstruct_prepared_transactions_initial_sync.js
+++ b/jstests/replsets/reconstruct_prepared_transactions_initial_sync.js
@@ -129,7 +129,7 @@ replTest.awaitSecondaryNodes();
jsTestLog("Initial sync completed");
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
// Make sure that while reading from the node that went through initial sync, we can't read
diff --git a/jstests/replsets/reconstruct_prepared_transactions_initial_sync_index_build.js b/jstests/replsets/reconstruct_prepared_transactions_initial_sync_index_build.js
index 3574010f636..38f7f431ca2 100644
--- a/jstests/replsets/reconstruct_prepared_transactions_initial_sync_index_build.js
+++ b/jstests/replsets/reconstruct_prepared_transactions_initial_sync_index_build.js
@@ -106,7 +106,7 @@ replTest.awaitSecondaryNodes();
jsTestLog("Initial sync completed");
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
// Make sure that while reading from the node that went through initial sync, we can't read
diff --git a/jstests/replsets/reconstruct_prepared_transactions_initial_sync_no_oplog_application.js b/jstests/replsets/reconstruct_prepared_transactions_initial_sync_no_oplog_application.js
index dbc2c05dfff..d5b0eb39898 100644
--- a/jstests/replsets/reconstruct_prepared_transactions_initial_sync_no_oplog_application.js
+++ b/jstests/replsets/reconstruct_prepared_transactions_initial_sync_no_oplog_application.js
@@ -80,7 +80,7 @@ replTest.awaitSecondaryNodes();
jsTestLog("Initial sync completed");
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
// Make sure that while reading from the node that went through initial sync, we can't read
diff --git a/jstests/replsets/reconstruct_prepared_transactions_initial_sync_on_oplog_seed.js b/jstests/replsets/reconstruct_prepared_transactions_initial_sync_on_oplog_seed.js
index 85e4b4e9874..f5100c39e35 100644
--- a/jstests/replsets/reconstruct_prepared_transactions_initial_sync_on_oplog_seed.js
+++ b/jstests/replsets/reconstruct_prepared_transactions_initial_sync_on_oplog_seed.js
@@ -107,7 +107,7 @@ PrepareHelpers.awaitMajorityCommitted(replTest, prepareTimestamp);
jsTestLog("Initial sync completed");
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
const secondaryColl = secondary.getDB(dbName).getCollection(collName);
jsTestLog("Checking that the transaction is properly prepared");
diff --git a/jstests/replsets/recover_prepared_transactions_startup_secondary_application.js b/jstests/replsets/recover_prepared_transactions_startup_secondary_application.js
index 31845da9629..56f40a8793f 100644
--- a/jstests/replsets/recover_prepared_transactions_startup_secondary_application.js
+++ b/jstests/replsets/recover_prepared_transactions_startup_secondary_application.js
@@ -82,7 +82,7 @@ PrepareHelpers.awaitMajorityCommitted(replTest, prepareTimestamp2);
// Wait for the node to complete recovery before trying to read from it.
replTest.awaitSecondaryNodes();
-secondary.setSlaveOk();
+secondary.setSecondaryOk();
jsTestLog("Checking that the first transaction is properly prepared");
diff --git a/jstests/replsets/rename_collection_temp.js b/jstests/replsets/rename_collection_temp.js
index dc6ffd6f84a..1bf716784d6 100644
--- a/jstests/replsets/rename_collection_temp.js
+++ b/jstests/replsets/rename_collection_temp.js
@@ -54,7 +54,7 @@ replTest.awaitReplication();
var secondary = replTest.getSecondary();
var secondaryFoo = secondary.getDB("foo");
-secondaryFoo.permanentColl.setSlaveOk(true);
+secondaryFoo.permanentColl.setSecondaryOk();
// Get the information on the secondary to ensure it was replicated correctly.
checkCollectionTemp(secondaryFoo, "permanentColl", false);
diff --git a/jstests/replsets/replset1.js b/jstests/replsets/replset1.js
index 8225422338d..35ceb70121f 100644
--- a/jstests/replsets/replset1.js
+++ b/jstests/replsets/replset1.js
@@ -104,7 +104,7 @@ var doTest = function(signal) {
var secondaries = replTest.getSecondaries();
assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
secondaries.forEach(function(secondary) {
- secondary.setSlaveOk();
+ secondary.setSecondaryOk();
var count = secondary.getDB("bar").runCommand({count: "bar"});
printjson(count);
assert.eq(1000, count.n, "secondary count wrong: " + secondary);
@@ -118,7 +118,7 @@ var doTest = function(signal) {
var t = db.foo;
var ts = secondaries.map(function(z) {
- z.setSlaveOk();
+ z.setSecondaryOk();
return z.getDB("foo").foo;
});
diff --git a/jstests/replsets/replset2.js b/jstests/replsets/replset2.js
index 3c9b9613eed..38134794dfb 100644
--- a/jstests/replsets/replset2.js
+++ b/jstests/replsets/replset2.js
@@ -29,7 +29,7 @@ doTest = function(signal) {
var secondaries = replTest.getSecondaries();
secondaries.forEach(function(secondary) {
- secondary.setSlaveOk();
+ secondary.setSecondaryOk();
});
// Test write concern with multiple inserts.
diff --git a/jstests/replsets/replset5.js b/jstests/replsets/replset5.js
index 5488d8a9cd0..9ea1424a426 100644
--- a/jstests/replsets/replset5.js
+++ b/jstests/replsets/replset5.js
@@ -55,8 +55,8 @@ if (wcError != null) {
}
var secondaries = replTest.getSecondaries();
-secondaries[0].setSlaveOk();
-secondaries[1].setSlaveOk();
+secondaries[0].setSecondaryOk();
+secondaries[1].setSecondaryOk();
var secondary0Count = secondaries[0].getDB(testDB).foo.find().itcount();
assert(secondary0Count == docNum,
diff --git a/jstests/replsets/replset6.js b/jstests/replsets/replset6.js
index 40998d7f4f2..fd33175d823 100644
--- a/jstests/replsets/replset6.js
+++ b/jstests/replsets/replset6.js
@@ -10,7 +10,7 @@ var p = rt.getPrimary();
rt.awaitSecondaryNodes();
var secondaries = rt.getSecondaries();
s = secondaries[0];
-s.setSlaveOk();
+s.setSecondaryOk();
admin = p.getDB("admin");
debug = function(foo) {}; // print( foo ); }
diff --git a/jstests/replsets/resync_majority_member.js b/jstests/replsets/resync_majority_member.js
index 4ab48f043ea..df0d233b4e3 100644
--- a/jstests/replsets/resync_majority_member.js
+++ b/jstests/replsets/resync_majority_member.js
@@ -99,8 +99,8 @@ assert.soon(() => {
});
// Observe that the old write does not exist anywhere in the set.
-syncSource.setSlaveOk();
-resyncNode.setSlaveOk();
+syncSource.setSecondaryOk();
+resyncNode.setSecondaryOk();
assert.eq(0, syncSource.getDB(dbName)[collName].find(disappearingDoc).itcount());
assert.eq(0, resyncNode.getDB(dbName)[collName].find(disappearingDoc).itcount());
diff --git a/jstests/replsets/rollback_auth.js b/jstests/replsets/rollback_auth.js
index 0aa7995bdc2..372f84ce645 100644
--- a/jstests/replsets/rollback_auth.js
+++ b/jstests/replsets/rollback_auth.js
@@ -47,8 +47,8 @@ replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
var master = replTest.getPrimary();
var a_conn = conns[0];
var b_conn = conns[1];
-a_conn.setSlaveOk();
-b_conn.setSlaveOk();
+a_conn.setSecondaryOk();
+b_conn.setSecondaryOk();
var A = a_conn.getDB("admin");
var B = b_conn.getDB("admin");
var a = a_conn.getDB("test");
diff --git a/jstests/replsets/rollback_creates_rollback_directory.js b/jstests/replsets/rollback_creates_rollback_directory.js
index 3cb47eb65a2..db795769bdf 100644
--- a/jstests/replsets/rollback_creates_rollback_directory.js
+++ b/jstests/replsets/rollback_creates_rollback_directory.js
@@ -31,8 +31,8 @@ function runRollbackDirectoryTest(shouldCreateRollbackFiles) {
var master = replTest.getPrimary();
var a_conn = conns[0];
var b_conn = conns[1];
- a_conn.setSlaveOk();
- b_conn.setSlaveOk();
+ a_conn.setSecondaryOk();
+ b_conn.setSecondaryOk();
var A = a_conn.getDB("test");
var B = b_conn.getDB("test");
var Apath = replTest.getDbPath(a_conn) + '/';
diff --git a/jstests/replsets/rollback_crud_op_sequences.js b/jstests/replsets/rollback_crud_op_sequences.js
index a2e89332141..cd42c303a96 100644
--- a/jstests/replsets/rollback_crud_op_sequences.js
+++ b/jstests/replsets/rollback_crud_op_sequences.js
@@ -45,10 +45,10 @@ replTest.initiate({
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
var master = replTest.getPrimary();
var a_conn = conns[0];
-a_conn.setSlaveOk();
+a_conn.setSecondaryOk();
var A = a_conn.getDB("admin");
var b_conn = conns[1];
-b_conn.setSlaveOk();
+b_conn.setSecondaryOk();
var B = b_conn.getDB("admin");
assert.eq(master, conns[0], "conns[0] assumed to be master");
assert.eq(a_conn, master);
diff --git a/jstests/replsets/rollback_ddl_op_sequences.js b/jstests/replsets/rollback_ddl_op_sequences.js
index aff9cedaa39..62b2fb9cae2 100644
--- a/jstests/replsets/rollback_ddl_op_sequences.js
+++ b/jstests/replsets/rollback_ddl_op_sequences.js
@@ -54,10 +54,10 @@ replTest.initiate({
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
var master = replTest.getPrimary();
var a_conn = conns[0];
-a_conn.setSlaveOk();
+a_conn.setSecondaryOk();
var A = a_conn.getDB("admin");
var b_conn = conns[1];
-b_conn.setSlaveOk();
+b_conn.setSecondaryOk();
var B = b_conn.getDB("admin");
assert.eq(master, conns[0], "conns[0] assumed to be master");
assert.eq(a_conn, master);
diff --git a/jstests/replsets/rslib.js b/jstests/replsets/rslib.js
index 65567450c96..b53a5030d42 100644
--- a/jstests/replsets/rslib.js
+++ b/jstests/replsets/rslib.js
@@ -147,7 +147,7 @@ reconnect = function(conn) {
};
getLatestOp = function(server) {
- server.getDB("admin").getMongo().setSlaveOk();
+ server.getDB("admin").getMongo().setSecondaryOk();
var log = server.getDB("local")['oplog.rs'];
var cursor = log.find({}).sort({'$natural': -1}).limit(1);
if (cursor.hasNext()) {
@@ -157,7 +157,7 @@ getLatestOp = function(server) {
};
getLeastRecentOp = function({server, readConcern}) {
- server.getDB("admin").getMongo().setSlaveOk();
+ server.getDB("admin").getMongo().setSecondaryOk();
const oplog = server.getDB("local").oplog.rs;
const cursor = oplog.find().sort({$natural: 1}).limit(1).readConcern(readConcern);
if (cursor.hasNext()) {
diff --git a/jstests/replsets/server8070.js b/jstests/replsets/server8070.js
index 876a768fd7a..5bc4fd8f60d 100644
--- a/jstests/replsets/server8070.js
+++ b/jstests/replsets/server8070.js
@@ -36,8 +36,8 @@ replSet.initiate({
// set up common points of access
var master = replSet.getPrimary();
var primary = master.getDB("foo");
-replSet.nodes[1].setSlaveOk();
-replSet.nodes[2].setSlaveOk();
+replSet.nodes[1].setSecondaryOk();
+replSet.nodes[2].setSecondaryOk();
var member2 = replSet.nodes[1].getDB("admin");
var member3 = replSet.nodes[2].getDB("admin");
diff --git a/jstests/replsets/slavedelay3.js b/jstests/replsets/slavedelay3.js
index 9d09fa4486c..1d12d22912b 100644
--- a/jstests/replsets/slavedelay3.js
+++ b/jstests/replsets/slavedelay3.js
@@ -17,7 +17,7 @@ var secondaryConns = replTest.getSecondaries();
var secondaries = [];
for (var i in secondaryConns) {
var d = secondaryConns[i].getDB(name);
- d.getMongo().setSlaveOk();
+ d.getMongo().setSecondaryOk();
secondaries.push(d);
}
diff --git a/jstests/replsets/slaveok_read_pref.js b/jstests/replsets/slaveok_read_pref.js
index 9fc11600e8d..e35f36e9c97 100644
--- a/jstests/replsets/slaveok_read_pref.js
+++ b/jstests/replsets/slaveok_read_pref.js
@@ -1,5 +1,5 @@
-// Test that slaveOk is implicitly allowed for queries on a secondary with a read preference other
-// than 'primary', and that queries which do have 'primary' read preference fail.
+// Test that secondaryOk is implicitly allowed for queries on a secondary with a read preference
+// other than 'primary', and that queries which do have 'primary' read preference fail.
(function() {
"use strict";
@@ -28,18 +28,18 @@ const secDB = rst.getSecondary().getDB(jsTestName());
for (let readMode of ["commands", "legacy"]) {
for (let readPref of readPrefs) {
- for (let slaveOk of [true, false]) {
- const testType = {readMode: readMode, readPref: readPref, slaveOk: slaveOk};
+ for (let secondaryOk of [true, false]) {
+ const testType = {readMode: readMode, readPref: readPref, secondaryOk: secondaryOk};
secDB.getMongo().forceReadMode(readMode);
- secDB.getMongo().setSlaveOk(slaveOk);
+ secDB.getMongo().setSecondaryOk(secondaryOk);
const cursor = (readPref ? secDB.test.find().readPref(readPref) : secDB.test.find());
- if (readPref === "primary" || (!readPref && !slaveOk)) {
+ if (readPref === "primary" || (!readPref && !secondaryOk)) {
// Attempting to run the query throws an error of type NotPrimaryNoSecondaryOk.
- const slaveOkErr = assert.throws(() => cursor.itcount(), [], tojson(testType));
- assert.commandFailedWithCode(slaveOkErr, ErrorCodes.NotPrimaryNoSecondaryOk);
+ const secondaryOkErr = assert.throws(() => cursor.itcount(), [], tojson(testType));
+ assert.commandFailedWithCode(secondaryOkErr, ErrorCodes.NotPrimaryNoSecondaryOk);
} else {
// Succeeds for all non-primary readPrefs, and for no readPref iff slaveOk.
const docCount = assert.doesNotThrow(() => cursor.itcount(), [], tojson(testType));
@@ -51,7 +51,7 @@ for (let readMode of ["commands", "legacy"]) {
function assertNotPrimaryNoSecondaryOk(func) {
secDB.getMongo().forceReadMode("commands");
- secDB.getMongo().setSlaveOk(false);
+ secDB.getMongo().setSecondaryOk(false);
secDB.getMongo().setReadPref("primary");
const res = assert.throws(func);
assert.commandFailedWithCode(res, ErrorCodes.NotPrimaryNoSecondaryOk);
@@ -59,7 +59,7 @@ function assertNotPrimaryNoSecondaryOk(func) {
// Test that agg with $out/$merge and non-inline mapReduce fail with 'NotPrimaryNoSecondaryOk' when
// directed at a secondary with "primary" read preference.
-const secondaryColl = secDB.slaveok_read_pref;
+const secondaryColl = secDB.secondaryok_read_pref;
assertNotPrimaryNoSecondaryOk(() => secondaryColl.aggregate([{$out: "target"}]).itcount());
assertNotPrimaryNoSecondaryOk(
() =>
diff --git a/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js b/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js
index 690151796b3..ec537f873fd 100644
--- a/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js
+++ b/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js
@@ -35,7 +35,7 @@ rst.awaitSecondaryNodes();
// Get the new secondary connection.
secondary = rst.getSecondary();
-secondary.setSlaveOk(true);
+secondary.setSecondaryOk();
const secondaryAdminDb = secondary.getDB("admin");
// Assert that the FCV document was cloned through initial sync on the secondary.
diff --git a/jstests/replsets/step_down_on_secondary.js b/jstests/replsets/step_down_on_secondary.js
index 64fcf73c3a2..5e8933d9017 100644
--- a/jstests/replsets/step_down_on_secondary.js
+++ b/jstests/replsets/step_down_on_secondary.js
@@ -93,7 +93,7 @@ jsTestLog("Do a read that hits a prepare conflict on the old primary");
const wTPrintPrepareConflictLogFailPoint = configureFailPoint(primary, "WTPrintPrepareConflictLog");
const joinReadThread = startParallelShell(() => {
- db.getMongo().setSlaveOk(true);
+ db.getMongo().setSecondaryOk();
oldPrimaryDB = db.getSiblingDB(TestData.dbName);
assert.commandFailedWithCode(oldPrimaryDB.runCommand({
diff --git a/jstests/replsets/transactions_only_allowed_on_primaries.js b/jstests/replsets/transactions_only_allowed_on_primaries.js
index 7b71cf3eb67..e987eda0205 100644
--- a/jstests/replsets/transactions_only_allowed_on_primaries.js
+++ b/jstests/replsets/transactions_only_allowed_on_primaries.js
@@ -27,8 +27,8 @@ replTest.initiate(config);
const primary = replTest.getPrimary();
const secondary = replTest.getSecondary();
-// Set slaveOk=true so that normal read commands would be allowed on the secondary.
-secondary.setSlaveOk(true);
+// Set secondaryOk=true so that normal read commands would be allowed on the secondary.
+secondary.setSecondaryOk();
// Create a test collection that we can run commands against.
const primaryDB = primary.getDB(dbName);
diff --git a/jstests/sharding/agg_mongos_slaveok.js b/jstests/sharding/agg_mongos_slaveok.js
index 287902092bc..01fb4286429 100644
--- a/jstests/sharding/agg_mongos_slaveok.js
+++ b/jstests/sharding/agg_mongos_slaveok.js
@@ -1,5 +1,5 @@
/**
- * Tests aggregate command against mongos with slaveOk. For more tests on read preference,
+ * Tests aggregate command against mongos with secondaryOk. For more tests on read preference,
* please refer to jstests/sharding/read_pref_cmd.js.
* @tags: [
* requires_replication,
@@ -21,12 +21,12 @@ var doTest = function(st, doSharded) {
}
testDB.user.insert({x: 10}, {writeConcern: {w: NODES}});
- testDB.setSlaveOk(true);
+ testDB.setSecondaryOk();
var secNode = st.rs0.getSecondary();
secNode.getDB('test').setProfilingLevel(2);
- // wait for mongos to recognize that the slave is up
+ // wait for mongos to recognize that the secondary is up
awaitRSClientHosts(st.s, secNode, {ok: true});
var res = testDB.runCommand({aggregate: 'user', pipeline: [{$project: {x: 1}}], cursor: {}});
diff --git a/jstests/sharding/all_shard_and_config_hosts_brought_down_one_by_one.js b/jstests/sharding/all_shard_and_config_hosts_brought_down_one_by_one.js
index b0bd0f59e8c..a11f8dbc694 100644
--- a/jstests/sharding/all_shard_and_config_hosts_brought_down_one_by_one.js
+++ b/jstests/sharding/all_shard_and_config_hosts_brought_down_one_by_one.js
@@ -39,7 +39,7 @@ jsTest.log('Config nodes up: 1 of 3, shard nodes up: 1 of 2: ' +
'Only queries will work (no shard primary)');
st.rs0.stop(0);
st.restartMongos(0);
-st.s0.setSlaveOk(true);
+st.s0.setSecondaryOk();
assert.eq([{_id: 0, count: 3}], st.s0.getDB('TestDB').TestColl.find().toArray());
jsTest.log('Config nodes up: 1 of 3, shard nodes up: 0 of 2: ' +
diff --git a/jstests/sharding/auth_repl.js b/jstests/sharding/auth_repl.js
index cd89c91f136..b806090fc3a 100644
--- a/jstests/sharding/auth_repl.js
+++ b/jstests/sharding/auth_repl.js
@@ -19,7 +19,7 @@ var testColl = testDB.user;
// before setting up authentication
assert.commandWorked(adminDB.runCommand({replSetGetStatus: 1}));
-conn.setSlaveOk();
+conn.setSecondaryOk();
assert.commandWorked(adminDB.runCommand({replSetGetStatus: 1}));
// Add admin user using direct connection to primary to simulate connection from remote host
@@ -38,19 +38,19 @@ assert.eq(1, testDB.auth('a', 'a'));
jsTest.log('Sending an authorized query that should be ok');
assert.commandWorked(testColl.insert({x: 1}, {writeConcern: {w: nodeCount}}));
-conn.setSlaveOk(true);
+conn.setSecondaryOk();
doc = testColl.findOne();
assert(doc != null);
doc = testColl.find().readPref('secondary').next();
assert(doc != null);
-conn.setSlaveOk(false);
+conn.setSecondaryOk(false);
doc = testColl.findOne();
assert(doc != null);
var queryToPriShouldFail = function() {
- conn.setSlaveOk(false);
+ conn.setSecondaryOk(false);
assert.throws(function() {
testColl.findOne();
@@ -63,7 +63,7 @@ var queryToPriShouldFail = function() {
};
var queryToSecShouldFail = function() {
- conn.setSlaveOk(true);
+ conn.setSecondaryOk();
assert.throws(function() {
testColl.findOne();
@@ -104,7 +104,7 @@ queryToPriShouldFail();
assert.eq(1, testDB.auth('a', 'a'));
// Find out the current cached secondary in the repl connection
-conn.setSlaveOk(true);
+conn.setSecondaryOk();
var serverInfo = testColl.find().readPref('secondary').explain().serverInfo;
var secNodeIdx = -1;
var secPortStr = serverInfo.port.toString();
diff --git a/jstests/sharding/auth_slaveok_routing.js b/jstests/sharding/auth_slaveok_routing.js
index 8eff7833c9b..1e573fc7c9e 100644
--- a/jstests/sharding/auth_slaveok_routing.js
+++ b/jstests/sharding/auth_slaveok_routing.js
@@ -1,5 +1,5 @@
/**
- * This tests whether slaveOk reads are properly routed through mongos in
+ * This tests whether secondaryOk reads are properly routed through mongos in
* an authenticated environment. This test also includes restarting the
* entire set, then querying afterwards.
*
@@ -59,11 +59,11 @@ priAdminDB.createUser({user: 'user', pwd: 'password', roles: jsTest.adminUserRol
{w: 3, wtimeout: 30000});
coll.drop();
-coll.setSlaveOk(true);
+coll.setSecondaryOk();
/* Secondaries should be up here, but they can still be in RECOVERY
* state, which will make the ReplicaSetMonitor mark them as
- * ok = false and not eligible for slaveOk queries.
+ * ok = false and not eligible for secondaryOk queries.
*/
awaitRSClientHosts(mongos, replTest.getSecondaries(), {ok: true, secondary: true});
@@ -90,7 +90,7 @@ for (var n = 0; n < nodeCount; n++) {
replTest.awaitSecondaryNodes();
-coll.setSlaveOk(true);
+coll.setSecondaryOk();
/* replSetMonitor does not refresh the nodes information when getting secondaries.
* A node that is previously labeled as secondary can now be a primary, so we
diff --git a/jstests/sharding/autodiscover_config_rs_from_secondary.js b/jstests/sharding/autodiscover_config_rs_from_secondary.js
index 9d9bd4adbd5..cc6ca3c11ae 100644
--- a/jstests/sharding/autodiscover_config_rs_from_secondary.js
+++ b/jstests/sharding/autodiscover_config_rs_from_secondary.js
@@ -53,7 +53,7 @@ var mongos = MongoRunner.runMongos({configdb: seedList});
rst.stop(1);
var admin = mongos.getDB('admin');
-mongos.setSlaveOk(true);
+mongos.setSecondaryOk();
assert.eq(1, admin.foo.findOne().a);
MongoRunner.stopMongos(mongos);
rst.stopSet();
diff --git a/jstests/sharding/balance_repl.js b/jstests/sharding/balance_repl.js
index 83c92ff37b1..fb501c979cb 100644
--- a/jstests/sharding/balance_repl.js
+++ b/jstests/sharding/balance_repl.js
@@ -44,7 +44,7 @@ var collPrimary = (new Mongo(s.s0.host)).getDB('TestDB').TestColl;
assert.eq(2100, collPrimary.find().itcount());
var collSlaveOk = (new Mongo(s.s0.host)).getDB('TestDB').TestColl;
-collSlaveOk.setSlaveOk();
+collSlaveOk.setSecondaryOk();
assert.eq(2100, collSlaveOk.find().itcount());
assert.commandWorked(s.s0.adminCommand({
diff --git a/jstests/sharding/cluster_create_indexes_always_routes_through_primary.js b/jstests/sharding/cluster_create_indexes_always_routes_through_primary.js
index 6c661e0abac..6b61bd12a68 100644
--- a/jstests/sharding/cluster_create_indexes_always_routes_through_primary.js
+++ b/jstests/sharding/cluster_create_indexes_always_routes_through_primary.js
@@ -1,5 +1,5 @@
// Ensure that a call to createIndexes in a sharded cluster will route to the primary, even when
-// setSlaveOk() is set to true.
+// setSecondaryOk() is set to true.
(function() {
'use strict';
@@ -12,7 +12,7 @@ assert.commandWorked(testDB.adminCommand({enableSharding: testDBName}));
assert.commandWorked(
testDB.adminCommand({shardCollection: testDB[collName].getFullName(), key: {x: 1}}));
-st.s.setSlaveOk(true);
+st.s.setSecondaryOk();
assert.commandWorked(
testDB.runCommand({createIndexes: collName, indexes: [{key: {a: 1}, name: "index"}]}));
diff --git a/jstests/sharding/config_rs_no_primary.js b/jstests/sharding/config_rs_no_primary.js
index 91ce74de45d..8bcf7e54cd4 100644
--- a/jstests/sharding/config_rs_no_primary.js
+++ b/jstests/sharding/config_rs_no_primary.js
@@ -43,9 +43,9 @@ var testOps = function(mongos) {
assert.throws(function() {
mongos.getDB('config').shards.findOne();
});
- mongos.setSlaveOk(true);
+ mongos.setSecondaryOk();
var shardDoc = mongos.getDB('config').shards.findOne();
- mongos.setSlaveOk(false);
+ mongos.setSecondaryOk(false);
assert.neq(null, shardDoc);
jsTestLog("Doing ops that require metadata writes and thus should fail against: " + mongos);
diff --git a/jstests/sharding/count_config_servers.js b/jstests/sharding/count_config_servers.js
index ded75607cd0..0904a873e52 100644
--- a/jstests/sharding/count_config_servers.js
+++ b/jstests/sharding/count_config_servers.js
@@ -13,7 +13,7 @@ TestData.skipCheckOrphans = true;
"use strict";
var st = new ShardingTest({name: 'sync_conn_cmd', shards: 0});
-st.s.setSlaveOk(true);
+st.s.setSecondaryOk();
var configDB = st.config;
var coll = configDB.test;
diff --git a/jstests/sharding/count_slaveok.js b/jstests/sharding/count_slaveok.js
index e527128a7cd..23612d96220 100644
--- a/jstests/sharding/count_slaveok.js
+++ b/jstests/sharding/count_slaveok.js
@@ -1,5 +1,5 @@
/**
- * Tests count and distinct using slaveOk. Also tests a scenario querying a set where only one
+ * Tests count and distinct using secondaryOk. Also tests a scenario querying a set where only one
* secondary is up.
*/
@@ -20,7 +20,7 @@ var rst = st.rs0;
// Insert data into replica set
var conn = new Mongo(st.s.host);
-var coll = conn.getCollection('test.countSlaveOk');
+var coll = conn.getCollection('test.countSecondaryOk');
coll.drop();
var bulk = coll.initializeUnorderedBulkOp();
@@ -51,9 +51,9 @@ awaitRSClientHosts(conn, sec, {ok: true, secondary: true});
// Make sure that mongos realizes that primary is already down
awaitRSClientHosts(conn, primary, {ok: false});
-// Need to check slaveOk=true first, since slaveOk=false will destroy conn in pool when
+// Need to check secondaryOk=true first, since secondaryOk=false will destroy conn in pool when
// master is down
-conn.setSlaveOk();
+conn.setSecondaryOk();
// count using the command path
assert.eq(30, coll.find({i: 0}).count());
@@ -62,14 +62,14 @@ assert.eq(30, coll.find({i: 0}).itcount());
assert.eq(10, coll.distinct("i").length);
try {
- conn.setSlaveOk(false);
- // Should throw exception, since not slaveOk'd
+ conn.setSecondaryOk(false);
+ // Should throw exception, since not secondaryOk'd
coll.find({i: 0}).count();
print("Should not reach here!");
assert(false);
} catch (e) {
- print("Non-slaveOk'd connection failed.");
+ print("Non-secondaryOk'd connection failed.");
}
st.stop();
diff --git a/jstests/sharding/error_propagation.js b/jstests/sharding/error_propagation.js
index 6f47075f753..6fa9b7da74c 100644
--- a/jstests/sharding/error_propagation.js
+++ b/jstests/sharding/error_propagation.js
@@ -8,7 +8,7 @@
var st = new ShardingTest({mongos: 1, shards: 1, rs: {nodes: 3}});
var db = st.getDB('test');
-db.setSlaveOk(true);
+db.setSecondaryOk();
assert.commandWorked(db.foo.insert({a: 1}, {writeConcern: {w: 3}}));
assert.commandWorked(db.runCommand(
diff --git a/jstests/sharding/mongos_rs_auth_shard_failure_tolerance.js b/jstests/sharding/mongos_rs_auth_shard_failure_tolerance.js
index 5cb277197b1..466c4314d45 100644
--- a/jstests/sharding/mongos_rs_auth_shard_failure_tolerance.js
+++ b/jstests/sharding/mongos_rs_auth_shard_failure_tolerance.js
@@ -160,9 +160,9 @@ gc(); // Clean up new connections
jsTest.log("Stopping primary of second shard...");
-mongosConnActive.setSlaveOk();
+mongosConnActive.setSecondaryOk();
mongosConnIdle = authDBUsers(new Mongo(mongos.host));
-mongosConnIdle.setSlaveOk();
+mongosConnIdle.setSecondaryOk();
// Need to save this node for later
var rs1Secondary = st.rs1.getSecondary();
@@ -192,13 +192,13 @@ assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne(
jsTest.log("Testing new connections with second primary down...");
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: -1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: 1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collUnsharded.toString()).findOne({_id: 1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
@@ -212,9 +212,9 @@ gc(); // Clean up new connections
jsTest.log("Stopping primary of first shard...");
-mongosConnActive.setSlaveOk();
+mongosConnActive.setSecondaryOk();
mongosConnIdle = authDBUsers(new Mongo(mongos.host));
-mongosConnIdle.setSlaveOk();
+mongosConnIdle.setSecondaryOk();
st.rs0.stop(st.rs0.getPrimary());
@@ -241,13 +241,13 @@ assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne(
jsTest.log("Testing new connections with first primary down...");
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: -1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: 1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collUnsharded.toString()).findOne({_id: 1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
@@ -261,9 +261,9 @@ gc(); // Clean up new connections
jsTest.log("Stopping second shard...");
-mongosConnActive.setSlaveOk();
+mongosConnActive.setSecondaryOk();
mongosConnIdle = authDBUsers(new Mongo(mongos.host));
-mongosConnIdle.setSlaveOk();
+mongosConnIdle.setSecondaryOk();
st.rs1.stop(rs1Secondary);
@@ -288,10 +288,10 @@ assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne(
jsTest.log("Testing new connections with second shard down...");
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: -1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collUnsharded.toString()).findOne({_id: 1}));
mongosConnNew = authDBUsers(new Mongo(mongos.host));
diff --git a/jstests/sharding/mongos_rs_shard_failure_tolerance.js b/jstests/sharding/mongos_rs_shard_failure_tolerance.js
index 34d68c45f6e..89dc4c07986 100644
--- a/jstests/sharding/mongos_rs_shard_failure_tolerance.js
+++ b/jstests/sharding/mongos_rs_shard_failure_tolerance.js
@@ -131,11 +131,11 @@ st.rs1.stop(st.rs1.getPrimary());
jsTest.log("Testing active connection with second primary down...");
// Reads with read prefs
-mongosConnActive.setSlaveOk();
+mongosConnActive.setSecondaryOk();
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: 1}));
assert.neq(null, mongosConnActive.getCollection(collUnsharded.toString()).findOne({_id: 1}));
-mongosConnActive.setSlaveOk(false);
+mongosConnActive.setSecondaryOk(false);
mongosConnActive.setReadPref("primary");
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: -1}));
@@ -145,14 +145,14 @@ assert.throws(function() {
assert.neq(null, mongosConnActive.getCollection(collUnsharded.toString()).findOne({_id: 1}));
// Ensure read prefs override slaveOK
-mongosConnActive.setSlaveOk();
+mongosConnActive.setSecondaryOk();
mongosConnActive.setReadPref("primary");
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.throws(function() {
mongosConnActive.getCollection(collSharded.toString()).findOne({_id: 1});
});
assert.neq(null, mongosConnActive.getCollection(collUnsharded.toString()).findOne({_id: 1}));
-mongosConnActive.setSlaveOk(false);
+mongosConnActive.setSecondaryOk(false);
mongosConnActive.setReadPref("secondary");
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: -1}));
@@ -187,11 +187,11 @@ assert.writeError(mongosConnIdle.getCollection(collSharded.toString()).insert({_
assert.commandWorked(mongosConnIdle.getCollection(collUnsharded.toString()).insert({_id: 6}, wc));
// Reads with read prefs
-mongosConnIdle.setSlaveOk();
+mongosConnIdle.setSecondaryOk();
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: 1}));
assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne({_id: 1}));
-mongosConnIdle.setSlaveOk(false);
+mongosConnIdle.setSecondaryOk(false);
mongosConnIdle.setReadPref("primary");
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: -1}));
@@ -201,14 +201,14 @@ assert.throws(function() {
assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne({_id: 1}));
// Ensure read prefs override slaveOK
-mongosConnIdle.setSlaveOk();
+mongosConnIdle.setSecondaryOk();
mongosConnIdle.setReadPref("primary");
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.throws(function() {
mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: 1});
});
assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne({_id: 1}));
-mongosConnIdle.setSlaveOk(false);
+mongosConnIdle.setSecondaryOk(false);
mongosConnIdle.setReadPref("secondary");
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: -1}));
@@ -234,13 +234,13 @@ jsTest.log("Testing new connections with second primary down...");
// Reads with read prefs
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: -1}));
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: 1}));
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collUnsharded.toString()).findOne({_id: 1}));
gc(); // Clean up new connections incrementally to compensate for slow win32 machine.
@@ -261,17 +261,17 @@ gc(); // Clean up new connections incrementally to compensate for slow win32 ma
// Ensure read prefs override slaveok
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
mongosConnNew.setReadPref("primary");
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: -1}));
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
mongosConnNew.setReadPref("primary");
assert.throws(function() {
mongosConnNew.getCollection(collSharded.toString()).findOne({_id: 1});
});
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
mongosConnNew.setReadPref("primary");
assert.neq(null, mongosConnNew.getCollection(collUnsharded.toString()).findOne({_id: 1}));
@@ -343,7 +343,7 @@ st.rs0.stop(st.rs0.getPrimary());
jsTest.log("Testing active connection with first primary down...");
-mongosConnActive.setSlaveOk();
+mongosConnActive.setSecondaryOk();
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: 1}));
assert.neq(null, mongosConnActive.getCollection(collUnsharded.toString()).findOne({_id: 1}));
@@ -358,7 +358,7 @@ assert.writeError(mongosConnIdle.getCollection(collSharded.toString()).insert({_
assert.writeError(mongosConnIdle.getCollection(collSharded.toString()).insert({_id: 9}));
assert.writeError(mongosConnIdle.getCollection(collUnsharded.toString()).insert({_id: 9}));
-mongosConnIdle.setSlaveOk();
+mongosConnIdle.setSecondaryOk();
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: 1}));
assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne({_id: 1}));
@@ -366,13 +366,13 @@ assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne(
jsTest.log("Testing new connections with first primary down...");
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: -1}));
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: 1}));
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collUnsharded.toString()).findOne({_id: 1}));
mongosConnNew = new Mongo(mongos.host);
@@ -392,7 +392,7 @@ st.rs1.stop(rs1Secondary);
jsTest.log("Testing active connection with second shard down...");
-mongosConnActive.setSlaveOk();
+mongosConnActive.setSecondaryOk();
assert.neq(null, mongosConnActive.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.neq(null, mongosConnActive.getCollection(collUnsharded.toString()).findOne({_id: 1}));
@@ -406,17 +406,17 @@ assert.writeError(mongosConnIdle.getCollection(collSharded.toString()).insert({_
assert.writeError(mongosConnIdle.getCollection(collSharded.toString()).insert({_id: 12}));
assert.writeError(mongosConnIdle.getCollection(collUnsharded.toString()).insert({_id: 12}));
-mongosConnIdle.setSlaveOk();
+mongosConnIdle.setSecondaryOk();
assert.neq(null, mongosConnIdle.getCollection(collSharded.toString()).findOne({_id: -1}));
assert.neq(null, mongosConnIdle.getCollection(collUnsharded.toString()).findOne({_id: 1}));
jsTest.log("Testing new connections with second shard down...");
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collSharded.toString()).findOne({_id: -1}));
mongosConnNew = new Mongo(mongos.host);
-mongosConnNew.setSlaveOk();
+mongosConnNew.setSecondaryOk();
assert.neq(null, mongosConnNew.getCollection(collUnsharded.toString()).findOne({_id: 1}));
mongosConnNew = new Mongo(mongos.host);
diff --git a/jstests/sharding/query/explain_read_pref.js b/jstests/sharding/query/explain_read_pref.js
index ce5e2cf47af..c3c51d85756 100644
--- a/jstests/sharding/query/explain_read_pref.js
+++ b/jstests/sharding/query/explain_read_pref.js
@@ -58,7 +58,7 @@ var testAllModes = function(conn, isMongos) {
var mode = args[0], tagSets = args[1], secExpected = args[2];
var testDB = conn.getDB('TestDB');
- conn.setSlaveOk(false); // purely rely on readPref
+ conn.setSecondaryOk(false); // purely rely on readPref
jsTest.log('Testing mode: ' + mode + ', tag sets: ' + tojson(tagSets));
// .explain().find()
diff --git a/jstests/sharding/read_pref.js b/jstests/sharding/read_pref.js
index 95c0e9697c3..9267cb18430 100644
--- a/jstests/sharding/read_pref.js
+++ b/jstests/sharding/read_pref.js
@@ -134,7 +134,7 @@ var doTest = function(useDollarQuerySyntax) {
var explainServer = getExplainServer(explain);
assert.neq(primaryNode.name, explainServer);
- conn.setSlaveOk();
+ conn.setSecondaryOk();
// It should also work with slaveOk
explain = getExplain("secondary");
diff --git a/jstests/sharding/read_pref_cmd.js b/jstests/sharding/read_pref_cmd.js
index 2c2a7f3332b..f94dd924f45 100644
--- a/jstests/sharding/read_pref_cmd.js
+++ b/jstests/sharding/read_pref_cmd.js
@@ -165,7 +165,7 @@ let testConnReadPreference = function(conn, isMongos, rsNodes, {readPref, expect
let testDB = conn.getDB(kDbName);
let shardedColl = conn.getCollection(kShardedNs);
- conn.setSlaveOk(false); // purely rely on readPref
+ conn.setSecondaryOk(false); // purely rely on readPref
conn.setReadPref(readPref.mode, readPref.tagSets, readPref.hedge);
/**
@@ -387,7 +387,7 @@ let testCursorReadPreference = function(conn, isMongos, rsNodes, {readPref, expe
tojson(readPref.tagSets)}, hedge ${tojson(readPref.hedge)}`);
let testColl = conn.getCollection(kShardedNs);
- conn.setSlaveOk(false); // purely rely on readPref
+ conn.setSecondaryOk(false); // purely rely on readPref
let bulk = testColl.initializeUnorderedBulkOp();
for (let i = 0; i < kNumDocs; ++i) {
diff --git a/jstests/sharding/recovering_slaveok.js b/jstests/sharding/recovering_slaveok.js
index 512719b08b6..d9bcd44da87 100644
--- a/jstests/sharding/recovering_slaveok.js
+++ b/jstests/sharding/recovering_slaveok.js
@@ -1,6 +1,6 @@
/**
- * This tests that slaveOk'd queries in sharded setups get correctly routed when a slave goes into
- * RECOVERING state, and don't break
+ * This tests that secondaryOk'd queries in sharded setups get correctly routed when a slave goes
+ * into RECOVERING state, and don't break
*/
// Shard secondaries are restarted, which may cause that shard's primary to stepdown while it does
@@ -12,11 +12,11 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
load("jstests/replsets/rslib.js");
var shardTest =
- new ShardingTest({name: "recovering_slaveok", shards: 2, mongos: 2, other: {rs: true}});
+ new ShardingTest({name: "recovering_secondaryok", shards: 2, mongos: 2, other: {rs: true}});
var mongos = shardTest.s0;
var mongosSOK = shardTest.s1;
-mongosSOK.setSlaveOk();
+mongosSOK.setSecondaryOk();
var admin = mongos.getDB("admin");
var config = mongos.getDB("config");
@@ -50,7 +50,7 @@ shardTest.shardColl(coll,
/* dbname */ null,
/* waitForDelete */ true);
-print("3: test normal and slaveOk queries");
+print("3: test normal and secondaryOk queries");
// Make shardA and rsA the same
var shardA = shardTest.getShard(coll, {_id: -1});
@@ -87,7 +87,7 @@ print("6: stop non-RECOVERING secondary");
rsA.stop(goodSec);
-print("7: check our regular and slaveOk query");
+print("7: check our regular and secondaryOk query");
assert.eq(2, coll.find().itcount());
assert.eq(2, collSOk.find().itcount());
@@ -100,7 +100,7 @@ print("9: wait for recovery");
rsA.waitForState(rsA.getSecondaries(), ReplSetTest.State.SECONDARY, 5 * 60 * 1000);
-print("10: check our regular and slaveOk query");
+print("10: check our regular and secondaryOk query");
// We need to make sure our nodes are considered accessible from mongos - otherwise we fail
// See SERVER-7274
@@ -112,7 +112,7 @@ awaitRSClientHosts(coll.getMongo(), rsB.nodes, {ok: true});
awaitRSClientHosts(collSOk.getMongo(), [rsA.getSecondaries()[0]], {secondary: true, ok: true});
awaitRSClientHosts(collSOk.getMongo(), [rsB.getSecondaries()[0]], {secondary: true, ok: true});
-print("SlaveOK Query...");
+print("SecondaryOk Query...");
var sOKCount = collSOk.find().itcount();
var collCount = null;
diff --git a/jstests/sharding/session_info_in_oplog.js b/jstests/sharding/session_info_in_oplog.js
index 617d5759207..a7644fca599 100644
--- a/jstests/sharding/session_info_in_oplog.js
+++ b/jstests/sharding/session_info_in_oplog.js
@@ -329,7 +329,7 @@ replTest.initiate();
var priConn = replTest.getPrimary();
var secConn = replTest.getSecondary();
-secConn.setSlaveOk(true);
+secConn.setSecondaryOk();
runTests(priConn, priConn, secConn);
@@ -338,7 +338,7 @@ replTest.stopSet();
var st = new ShardingTest({shards: {rs0: {nodes: kNodes}}});
secConn = st.rs0.getSecondary();
-secConn.setSlaveOk(true);
+secConn.setSecondaryOk();
runTests(st.s, st.rs0.getPrimary(), secConn);
st.stop();
diff --git a/jstests/sharding/shard_aware_init_secondaries.js b/jstests/sharding/shard_aware_init_secondaries.js
index 59a8542f44b..f852c6e58a1 100644
--- a/jstests/sharding/shard_aware_init_secondaries.js
+++ b/jstests/sharding/shard_aware_init_secondaries.js
@@ -41,7 +41,7 @@ assert.commandWorked(priConn.getDB('admin').system.version.update(
shardIdentityQuery, shardIdentityUpdate, {upsert: true, writeConcern: {w: 2}}));
var secConn = replTest.getSecondary();
-secConn.setSlaveOk(true);
+secConn.setSecondaryOk();
var res = secConn.getDB('admin').runCommand({shardingState: 1});
@@ -55,7 +55,7 @@ replTest.waitForPrimary();
replTest.awaitSecondaryNodes();
secConn = replTest.getSecondary();
-secConn.setSlaveOk(true);
+secConn.setSecondaryOk();
res = secConn.getDB('admin').runCommand({shardingState: 1});
diff --git a/jstests/sharding/shard_identity_config_update.js b/jstests/sharding/shard_identity_config_update.js
index 3e668c5903c..43c10bbbd22 100644
--- a/jstests/sharding/shard_identity_config_update.js
+++ b/jstests/sharding/shard_identity_config_update.js
@@ -63,7 +63,7 @@ assert.soon(function() {
});
var secConn = st.rs0.getSecondary();
-secConn.setSlaveOk(true);
+secConn.setSecondaryOk();
assert.soon(function() {
return checkConfigStrUpdated(secConn, expectedConfigStr);
});
@@ -96,7 +96,7 @@ assert.soon(function() {
});
secConn = st.rs0.getSecondary();
-secConn.setSlaveOk(true);
+secConn.setSecondaryOk();
assert.soon(function() {
return checkConfigStrUpdated(secConn, origConfigConnStr);
});
diff --git a/jstests/sharding/shard_identity_rollback.js b/jstests/sharding/shard_identity_rollback.js
index d6e47fa3137..25dbc2e19e4 100644
--- a/jstests/sharding/shard_identity_rollback.js
+++ b/jstests/sharding/shard_identity_rollback.js
@@ -52,7 +52,7 @@ assert.eq(shardIdentityDoc.clusterId, res.clusterId);
// Ensure sharding state on the secondaries was *not* initialized
secondaries.forEach(function(secondary) {
- secondary.setSlaveOk(true);
+ secondary.setSecondaryOk();
res = secondary.getDB('admin').runCommand({shardingState: 1});
assert(!res.enabled, tojson(res));
});
@@ -105,7 +105,7 @@ try {
// specified. We do want to wait to be able to connect to the node here however, so we need to pass
// {waitForConnect: true}.
priConn = replTest.start(priConn.nodeId, {shardsvr: '', waitForConnect: true}, true);
-priConn.setSlaveOk();
+priConn.setSecondaryOk();
// Wait for the old primary to replicate the document that was written to the new primary while
// it was shut down.
diff --git a/jstests/sharding/shard_insert_getlasterror_w2.js b/jstests/sharding/shard_insert_getlasterror_w2.js
index 7bde30b2dc5..a4a0f5c540f 100644
--- a/jstests/sharding/shard_insert_getlasterror_w2.js
+++ b/jstests/sharding/shard_insert_getlasterror_w2.js
@@ -70,7 +70,7 @@ replSet1.stop(secondary2);
replSet1.waitForState(primary, ReplSetTest.State.SECONDARY);
testDB.getMongo().adminCommand({setParameter: 1, logLevel: 1});
-testDB.getMongo().setSlaveOk();
+testDB.getMongo().setSecondaryOk();
print("trying some queries");
assert.soon(function() {
try {
diff --git a/jstests/slow1/replsets_priority1.js b/jstests/slow1/replsets_priority1.js
index 3ff6c058cc7..4dea828c793 100644
--- a/jstests/slow1/replsets_priority1.js
+++ b/jstests/slow1/replsets_priority1.js
@@ -146,9 +146,9 @@ for (var i = 0; i < n; i++) {
assert.soon(function() {
var versions = [0, 0];
var secondaries = rs.getSecondaries();
- secondaries[0].setSlaveOk();
+ secondaries[0].setSecondaryOk();
versions[0] = secondaries[0].getDB("local").system.replset.findOne().version;
- secondaries[1].setSlaveOk();
+ secondaries[1].setSecondaryOk();
versions[1] = secondaries[1].getDB("local").system.replset.findOne().version;
return versions[0] == config.version && versions[1] == config.version;
});
diff --git a/jstests/ssl/mongo_uri_secondaries.js b/jstests/ssl/mongo_uri_secondaries.js
index a4ed1eae93c..73cca540c80 100644
--- a/jstests/ssl/mongo_uri_secondaries.js
+++ b/jstests/ssl/mongo_uri_secondaries.js
@@ -39,7 +39,7 @@ const subShellCommand = function(hosts) {
for (var i = 0; i < 10; i++) {
var db = Ms[i].getDB("test");
- db.setSlaveOk(true);
+ db.setSecondaryOk();
db.col.find().readPref("secondary").toArray();
}
};
diff --git a/src/mongo/shell/collection.js b/src/mongo/shell/collection.js
index 20522653bc2..bf5aa3a2653 100644
--- a/src/mongo/shell/collection.js
+++ b/src/mongo/shell/collection.js
@@ -1322,9 +1322,7 @@ DBCollection.prototype.getSlaveOk = function() {
return this.getSecondaryOk();
};
-DBCollection.prototype.setSecondaryOk = function(value) {
- if (value === undefined)
- value = true;
+DBCollection.prototype.setSecondaryOk = function(value = true) {
this._secondaryOk = value;
};
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js
index 477dc95a60c..16c109e9cb4 100644
--- a/src/mongo/shell/db.js
+++ b/src/mongo/shell/db.js
@@ -1244,7 +1244,7 @@ DB.autocomplete = function(obj) {
return ret;
};
-DB.prototype.setSlaveOk = function(value) {
+DB.prototype.setSlaveOk = function(value = true) {
print(
"WARNING: setSlaveOk() is deprecated and may be removed in the next major release. Please use setSecondaryOk() instead.");
this.setSecondaryOk(value);
@@ -1256,9 +1256,7 @@ DB.prototype.getSlaveOk = function() {
return this.getSecondaryOk();
};
-DB.prototype.setSecondaryOk = function(value) {
- if (value == undefined)
- value = true;
+DB.prototype.setSecondaryOk = function(value = true) {
this._secondaryOk = value;
};
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js
index 23a2cf775f1..5beecf5646d 100644
--- a/src/mongo/shell/mongo.js
+++ b/src/mongo/shell/mongo.js
@@ -39,9 +39,7 @@ Mongo.prototype.getSlaveOk = function() {
return this.getSecondaryOk();
};
-Mongo.prototype.setSecondaryOk = function(value) {
- if (value == undefined)
- value = true;
+Mongo.prototype.setSecondaryOk = function(value = true) {
this.secondaryOk = value;
};