summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildscripts/resmokeconfig/suites/multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_jscore_passthrough.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_kill_primary_jscore_passthrough.yml4
-rw-r--r--buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_stepdown_primary_jscore_passthrough.yml4
-rw-r--r--buildscripts/resmokeconfig/suites/multi_stmt_txn_jscore_passthrough_with_migration.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/sharded_multi_stmt_txn_jscore_passthrough.yml3
-rw-r--r--jstests/core/awaitdata_getmore_cmd.js1
-rw-r--r--jstests/core/basic1.js3
-rw-r--r--jstests/core/currentop.js3
-rw-r--r--jstests/core/currentop_shell.js24
-rw-r--r--jstests/core/killop_drop_collection.js4
-rw-r--r--jstests/core/mr_killop.js2
-rw-r--r--jstests/libs/override_methods/network_error_and_txn_override.js7
-rw-r--r--jstests/libs/override_methods/override_helpers.js1
-rw-r--r--jstests/libs/override_methods/set_read_and_write_concerns.js5
-rw-r--r--jstests/libs/override_methods/set_read_preference_secondary.js10
-rw-r--r--src/mongo/shell/db.js12
18 files changed, 57 insertions, 38 deletions
diff --git a/buildscripts/resmokeconfig/suites/multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough.yml
index 58c110d8888..c6d5732c8f7 100644
--- a/buildscripts/resmokeconfig/suites/multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough.yml
@@ -272,6 +272,9 @@ selector:
# Transaction-continuing commands must use the same API parameters as the first command, so tests
# that use API parameters cannot be run with transactions.
- uses_api_parameters
+ # "Cowardly refusing to run test with transaction override enabled when it uses
+ # startParallelShell()"
+ - uses_parallel_shell
executor:
archive:
diff --git a/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_jscore_passthrough.yml
index 92b3f59a509..64a6ae13f6f 100644
--- a/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_jscore_passthrough.yml
@@ -290,6 +290,9 @@ selector:
# Transaction-continuing commands must use the same API parameters as the first command, so tests
# that use API parameters cannot be run with transactions.
- uses_api_parameters
+ # "Cowardly refusing to run test with transaction override enabled when it uses
+ # startParallelShell()"
+ - uses_parallel_shell
executor:
archive:
diff --git a/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_kill_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_kill_primary_jscore_passthrough.yml
index dbf6cc4d299..beedb9dbdd8 100644
--- a/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_kill_primary_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_kill_primary_jscore_passthrough.yml
@@ -316,7 +316,7 @@ selector:
- assumes_unsharded_collection
- cannot_create_unique_index_when_using_hashed_shard_key
- # The next three tags correspond to the special errors thrown by the
+ # The next five tags correspond to the special errors thrown by the
# fail_unclean_shutdown_incompatible_commands.js override when it refuses to run commands that are
# inaccurate after an unclean shutdown. Above each tag is the message that causes the tag to be
# warranted.
@@ -329,6 +329,8 @@ selector:
- requires_collstats
# "Cowardly fail if unbounded dataSize is run with a mongod that had an unclean shutdown: ..."
- requires_datasize
+ # "Cowardly fail if startParallelShell is run with a mongod that had an unclean shutdown: ..."
+ - uses_parallel_shell
# system.profile collection doesn't exist on mongos. Also, transactions are not allowed to operate
# on capped collections.
- requires_profiling
diff --git a/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_stepdown_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_stepdown_primary_jscore_passthrough.yml
index 5aa46fbe0ab..16a1ea2dd33 100644
--- a/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_stepdown_primary_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_stepdown_primary_jscore_passthrough.yml
@@ -317,7 +317,7 @@ selector:
- assumes_unsharded_collection
- cannot_create_unique_index_when_using_hashed_shard_key
- # The next three tags correspond to the special errors thrown by the
+ # The next five tags correspond to the special errors thrown by the
# fail_unclean_shutdown_incompatible_commands.js override when it refuses to run commands that are
# inaccurate after an unclean shutdown. Above each tag is the message that causes the tag to be
# warranted.
@@ -330,6 +330,8 @@ selector:
- requires_collstats
# "Cowardly fail if unbounded dataSize is run with a mongod that had an unclean shutdown: ..."
- requires_datasize
+ # "Cowardly fail if startParallelShell is run with a mongod that had an unclean shutdown: ..."
+ - uses_parallel_shell
# system.profile collection doesn't exist on mongos.
- requires_profiling
# Snapshot reads in transactions are banned on capped collections.
diff --git a/buildscripts/resmokeconfig/suites/multi_stmt_txn_jscore_passthrough_with_migration.yml b/buildscripts/resmokeconfig/suites/multi_stmt_txn_jscore_passthrough_with_migration.yml
index 3c3a9dfbc23..6fbfc542e46 100644
--- a/buildscripts/resmokeconfig/suites/multi_stmt_txn_jscore_passthrough_with_migration.yml
+++ b/buildscripts/resmokeconfig/suites/multi_stmt_txn_jscore_passthrough_with_migration.yml
@@ -303,6 +303,9 @@ selector:
# Transaction-continuing commands must use the same API parameters as the first command, so tests
# that use API parameters cannot be run with transactions.
- uses_api_parameters
+ # "Cowardly refusing to run test with transaction override enabled when it uses
+ # startParallelShell()"
+ - uses_parallel_shell
executor:
archive:
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml
index d496dd240c8..30686edda62 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml
@@ -232,6 +232,9 @@ selector:
# Transaction-continuing commands must use the same API parameters as the first command, so tests
# that use API parameters cannot be run with transactions.
- uses_api_parameters
+ # "Cowardly refusing to run test with transaction override enabled when it uses
+ # startParallelShell()"
+ - uses_parallel_shell
executor:
archive:
diff --git a/buildscripts/resmokeconfig/suites/sharded_multi_stmt_txn_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_multi_stmt_txn_jscore_passthrough.yml
index 357798e1206..703a6f805a8 100644
--- a/buildscripts/resmokeconfig/suites/sharded_multi_stmt_txn_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharded_multi_stmt_txn_jscore_passthrough.yml
@@ -255,6 +255,9 @@ selector:
# Transaction-continuing commands must use the same API parameters as the first command, so tests
# that use API parameters cannot be run with transactions.
- uses_api_parameters
+ # "Cowardly refusing to run test with transaction override enabled when it uses
+ # startParallelShell()"
+ - uses_parallel_shell
executor:
archive:
diff --git a/jstests/core/awaitdata_getmore_cmd.js b/jstests/core/awaitdata_getmore_cmd.js
index b482e8a3085..fae96fbdc91 100644
--- a/jstests/core/awaitdata_getmore_cmd.js
+++ b/jstests/core/awaitdata_getmore_cmd.js
@@ -9,7 +9,6 @@
// requires_getmore,
// uses_multiple_connections,
// uses_parallel_shell,
-// assumes_read_concern_unchanged,
// ]
(function() {
diff --git a/jstests/core/basic1.js b/jstests/core/basic1.js
index 66c034dd6b0..cc2917fb5a3 100644
--- a/jstests/core/basic1.js
+++ b/jstests/core/basic1.js
@@ -1,5 +1,4 @@
-// @tags: [does_not_support_stepdowns, assumes_read_concern_unchanged,
-// assumes_read_preference_unchanged ]
+// @tags: [does_not_support_stepdowns]
t = db.getCollection("basic1");
t.drop();
diff --git a/jstests/core/currentop.js b/jstests/core/currentop.js
index e1c577b9469..41c2e36110f 100644
--- a/jstests/core/currentop.js
+++ b/jstests/core/currentop.js
@@ -2,13 +2,10 @@
* Tests that long-running operations show up in currentOp and report the locks they are holding.
*
* @tags: [
- * assumes_read_preference_unchanged,
* assumes_superuser_permissions,
* # fsync command is not available on embedded
* incompatible_with_embedded,
* uses_parallel_shell,
- * # The aggregation stage $currentOp cannot run with a readConcern other than 'local'
- * assumes_read_concern_unchanged
* ]
*/
diff --git a/jstests/core/currentop_shell.js b/jstests/core/currentop_shell.js
index a1d570eaa0b..d171b54a1dd 100644
--- a/jstests/core/currentop_shell.js
+++ b/jstests/core/currentop_shell.js
@@ -10,8 +10,6 @@
* # node and the expected command is run on another, the latter will not show up in the
* # currentOp results.
* assumes_read_preference_unchanged,
- * # The aggregation stage $currentOp cannot run with a readConcern other than 'local'
- * assumes_read_concern_unchanged,
* ]
*/
@@ -95,16 +93,16 @@ res = db.adminCommand({currentOp: true, "ns": "test.currentOp_cursor"});
if (FixtureHelpers.isMongos(db) && FixtureHelpers.isSharded(coll)) {
// Assert currentOp truncation behavior for each shard in the cluster.
- assert(res.inprog.length >= 1);
+ assert(res.inprog.length >= 1, res);
res.inprog.forEach((result) => {
- assert.eq(result.op, "getmore");
- assert(result.cursor.originatingCommand.hasOwnProperty("$truncated"));
+ assert.eq(result.op, "getmore", result);
+ assert(result.cursor.originatingCommand.hasOwnProperty("$truncated"), result);
});
} else {
// Assert currentOp truncation behavior for unsharded collections.
- assert.eq(res.inprog.length, 1);
- assert.eq(res.inprog[0].op, "command");
- assert(res.inprog[0].command.hasOwnProperty("$truncated"));
+ assert.eq(res.inprog.length, 1, res);
+ assert.eq(res.inprog[0].op, "command", res);
+ assert(res.inprog[0].command.hasOwnProperty("$truncated"), res);
}
const log = FixtureHelpers.getPrimaryForNodeHostingDatabase(db).adminCommand({getLog: "global"});
@@ -121,14 +119,14 @@ const shellHelperTest = startShellWithOp("currentOp_shell");
res = db.currentOp({"ns": "test.currentOp_cursor"});
if (FixtureHelpers.isMongos(db) && FixtureHelpers.isSharded(coll)) {
- assert(res.inprog.length >= 1);
+ assert(res.inprog.length >= 1, res);
res.inprog.forEach((result) => {
- assert.eq(result.op, "getmore");
- assert(!result.cursor.originatingCommand.hasOwnProperty("$truncated"));
+ assert.eq(result.op, "getmore", result);
+ assert(!result.cursor.originatingCommand.hasOwnProperty("$truncated"), result);
});
} else {
- assert.eq(res.inprog.length, 1);
- assert(!res.inprog[0].command.hasOwnProperty("$truncated"));
+ assert.eq(res.inprog.length, 1, res);
+ assert(!res.inprog[0].command.hasOwnProperty("$truncated"), res);
}
res.inprog.forEach((op) => {
diff --git a/jstests/core/killop_drop_collection.js b/jstests/core/killop_drop_collection.js
index b09ee1d246c..b993e574519 100644
--- a/jstests/core/killop_drop_collection.js
+++ b/jstests/core/killop_drop_collection.js
@@ -8,9 +8,7 @@
* assumes_superuser_permissions,
* # Uses index building in background
* requires_background_index,
- * uses_parallel_shell,
- * assumes_read_concern_unchanged,
- * assumes_read_preference_unchanged
+ * uses_parallel_shell
* ]
*/
(function() {
diff --git a/jstests/core/mr_killop.js b/jstests/core/mr_killop.js
index 9287490657a..be994735823 100644
--- a/jstests/core/mr_killop.js
+++ b/jstests/core/mr_killop.js
@@ -6,8 +6,6 @@
// uses_map_reduce_with_temp_collections,
// uses_multiple_connections,
// uses_parallel_shell,
-// assumes_read_preference_unchanged,
-// assumes_read_concern_unchanged,
// ]
(function() {
"use strict";
diff --git a/jstests/libs/override_methods/network_error_and_txn_override.js b/jstests/libs/override_methods/network_error_and_txn_override.js
index 4de5cd9ba65..adf8a46a7fd 100644
--- a/jstests/libs/override_methods/network_error_and_txn_override.js
+++ b/jstests/libs/override_methods/network_error_and_txn_override.js
@@ -414,9 +414,10 @@ function appendReadAndWriteConcern(conn, dbName, cmdName, cmdObj) {
}
} else if (cmdName === "aggregate") {
if (OverrideHelpers.isAggregationWithListLocalSessionsStage(cmdName, cmdObj) ||
- OverrideHelpers.isAggregationWithChangeStreamStage(cmdName, cmdObj)) {
- // The $listLocalSessions stage can only be used with readConcern={level: "local"},
- // and the $changeStream stage can only be used with
+ OverrideHelpers.isAggregationWithChangeStreamStage(cmdName, cmdObj) ||
+ OverrideHelpers.isAggregationWithCurrentOpStage(cmdName, cmdObj)) {
+ // The $listLocalSessions and $currentOp stages can only be used with
+ // readConcern={level: "local"}, and the $changeStream stage can only be used with
// readConcern={level: "majority"}.
shouldForceReadConcern = false;
}
diff --git a/jstests/libs/override_methods/override_helpers.js b/jstests/libs/override_methods/override_helpers.js
index 8afeb999332..f4db0871bcf 100644
--- a/jstests/libs/override_methods/override_helpers.js
+++ b/jstests/libs/override_methods/override_helpers.js
@@ -101,6 +101,7 @@ var OverrideHelpers = (function() {
isAggregationWithListLocalSessionsStage:
makeIsAggregationWithFirstStage("$listLocalSessions"),
isAggregationWithOutOrMergeStage: isAggregationWithOutOrMergeStage,
+ isAggregationWithCurrentOpStage: makeIsAggregationWithFirstStage("$currentOp"),
isAggregationWithChangeStreamStage: makeIsAggregationWithFirstStage("$changeStream"),
isMapReduceWithInlineOutput: isMapReduceWithInlineOutput,
prependOverrideInParallelShell: prependOverrideInParallelShell,
diff --git a/jstests/libs/override_methods/set_read_and_write_concerns.js b/jstests/libs/override_methods/set_read_and_write_concerns.js
index 4679cf58092..9397c682010 100644
--- a/jstests/libs/override_methods/set_read_and_write_concerns.js
+++ b/jstests/libs/override_methods/set_read_and_write_concerns.js
@@ -87,6 +87,11 @@ function runCommandWithReadAndWriteConcerns(
shouldForceWriteConcern = false;
}
+ if (OverrideHelpers.isAggregationWithCurrentOpStage(commandName, commandObjUnwrapped)) {
+ // The $currentOp stage can only be used with readConcern={level: "local"}.
+ shouldForceReadConcern = false;
+ }
+
if (commandObjUnwrapped.explain) {
// Attempting to specify a readConcern while explaining an aggregation would always
// return an error prior to SERVER-30582 and it otherwise only compatible with
diff --git a/jstests/libs/override_methods/set_read_preference_secondary.js b/jstests/libs/override_methods/set_read_preference_secondary.js
index 9685449103e..68128b2ba93 100644
--- a/jstests/libs/override_methods/set_read_preference_secondary.js
+++ b/jstests/libs/override_methods/set_read_preference_secondary.js
@@ -117,6 +117,16 @@ function runCommandWithReadPreferenceSecondary(
shouldForceReadPreference = false;
}
+ if (commandName === "aggregate") {
+ if (OverrideHelpers.isAggregationWithCurrentOpStage(commandName, commandObjUnwrapped)) {
+ // Setting read preference secondary for an aggregation with $currentOp doesn't make
+ // much sense, since there's no guarantee *which* secondary you get results from. We
+ // will mirror the currentOp server command behavior here and maintain original read
+ // preference.
+ shouldForceReadPreference = false;
+ }
+ }
+
if (TestData.doNotOverrideReadPreference) {
// Use this TestData flag to allow certain runCommands to be exempted from
// setting secondary read preference.
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js
index 4adf56857c0..cabc4599cac 100644
--- a/src/mongo/shell/db.js
+++ b/src/mongo/shell/db.js
@@ -880,15 +880,9 @@ DB.prototype.currentOpCursor = function(arg) {
// The legacy db.currentOp() shell helper ignored any explicitly set read preference and used
// the default, with the ability to also run on secondaries. To preserve this behavior we will
- // temporarily set the session's read preference to "primaryPreferred".
- const session = this.getSession();
- const readPreference = session.getOptions().getReadPreference();
- try {
- session.getOptions().setReadPreference({mode: "primaryPreferred"});
- return this.getSiblingDB("admin").aggregate(pipeline);
- } finally {
- session.getOptions().setReadPreference(readPreference);
- }
+ // run the aggregate with read preference "primaryPreferred".
+ return this.getSiblingDB("admin").aggregate(pipeline,
+ {"$readPreference": {"mode": "primaryPreferred"}});
};
DB.prototype.killOp = function(op) {