0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 00:17:37 +01:00

SERVER-92024: Only provide JS_GC_ZEAL setting for mongo server processes. (#24954)

GitOrigin-RevId: 88dd3ef2b4325ca332b8e7e6180f1e8f9c7534ea
This commit is contained in:
Santiago Roche 2024-09-06 15:00:52 -04:00 committed by MongoDB Bot
parent 48e0502cd8
commit 876f66eb13
93 changed files with 287 additions and 48 deletions

View File

@ -113,6 +113,7 @@ DEFAULTS = {
"shell_seed": None,
"storage_engine": "wiredTiger",
"storage_engine_cache_size_gb": None,
"mozjs_js_gc_zeal": None,
"suite_files": "with_server",
"tag_files": [],
"test_files": [],
@ -722,3 +723,8 @@ REQUIRES_WORKLOAD_CONTAINER_SETUP = False
# Config fuzzer encryption options, this is only set when the fuzzer is run
CONFIG_FUZZER_ENCRYPTION_OPTS = None
# If resmoke is running on a build variant that specifies a mongo_mozjs_opts,
# we need a way to provide the JS_GC_ZEAL setting provided as part of the mongo_mozjs_opts
# exclusively to mongod/mongos.
MOZJS_JS_GC_ZEAL = None

View File

@ -524,6 +524,7 @@ or explicitly pass --installDir to the run subcommand of buildscripts/resmoke.py
_config.SHELL_SEED = config.pop("shell_seed")
_config.STAGGER_JOBS = config.pop("stagger_jobs") == "on"
_config.STORAGE_ENGINE_CACHE_SIZE = config.pop("storage_engine_cache_size_gb")
_config.MOZJS_JS_GC_ZEAL = config.pop("mozjs_js_gc_zeal")
_config.SUITE_FILES = config.pop("suite_files")
if _config.SUITE_FILES is not None:
_config.SUITE_FILES = _config.SUITE_FILES.split(",")

View File

@ -1658,6 +1658,13 @@ class RunPlugin(PluginInterface):
),
)
mongodb_server_options.add_argument(
"--mozjsJsGcZeal",
dest="mozjs_js_gc_zeal",
action="store",
help="sets JS_GC_ZEAL for mozjs.",
)
mongodb_server_options.add_argument(
"--majorityReadConcern",
action="store",

View File

@ -167,6 +167,7 @@ class _FixtureConfig(object):
self.NO_JOURNAL = config.NO_JOURNAL
self.STORAGE_ENGINE = config.STORAGE_ENGINE
self.STORAGE_ENGINE_CACHE_SIZE = config.STORAGE_ENGINE_CACHE_SIZE
self.MOZJS_JS_GC_ZEAL = config.MOZJS_JS_GC_ZEAL
self.WT_COLL_CONFIG = config.WT_COLL_CONFIG
self.WT_ENGINE_CONFIG = config.WT_ENGINE_CONFIG
self.WT_INDEX_CONFIG = config.WT_INDEX_CONFIG

View File

@ -1009,6 +1009,15 @@ class MongosLauncher(object):
DEFAULT_MONGOS_SHUTDOWN_TIMEOUT_MILLIS
)
# If a JS_GC_ZEAL value has been provided in the configuration under MOZJS_JS_GC_ZEAL,
# we inject this value directly as an environment variable to be passed to the spawned
# mongos process.
if self.config.MOZJS_JS_GC_ZEAL:
process_kwargs = self.fixturelib.default_if_none(process_kwargs, {}).copy()
env_vars = process_kwargs.setdefault("env_vars", {}).copy()
env_vars.setdefault("JS_GC_ZEAL", self.config.MOZJS_JS_GC_ZEAL)
process_kwargs["env_vars"] = env_vars
_add_testing_set_parameters(suite_set_parameters)
return self.fixturelib.mongos_program(

View File

@ -475,6 +475,15 @@ class MongodLauncher(object):
elif self.config.STORAGE_ENGINE == "wiredTiger" or self.config.STORAGE_ENGINE is None:
shortcut_opts["wiredTigerCacheSizeGB"] = self.config.STORAGE_ENGINE_CACHE_SIZE
# If a JS_GC_ZEAL value has been provided in the configuration under MOZJS_JS_GC_ZEAL,
# we inject this value directly as an environment variable to be passed to the spawned
# mongod process.
if self.config.MOZJS_JS_GC_ZEAL:
process_kwargs = self.fixturelib.default_if_none(process_kwargs, {}).copy()
env_vars = process_kwargs.setdefault("env_vars", {}).copy()
env_vars.setdefault("JS_GC_ZEAL", self.config.MOZJS_JS_GC_ZEAL)
process_kwargs["env_vars"] = env_vars
# These options are just flags, so they should not take a value.
opts_without_vals = "logappend"

View File

@ -73,6 +73,9 @@ class _SingleJSTestCase(interface.ProcessTestCase):
test_data["ignoreUnterminatedProcesses"] = False
test_data["ignoreChildProcessErrorCode"] = False
if config.MOZJS_JS_GC_ZEAL:
test_data["mozJSGCZeal"] = config.MOZJS_JS_GC_ZEAL
# The tests in 'timeseries' directory need to use a different logic for implicity sharding
# the collection. Make sure that we consider both unix and windows directory structures.
# Check if any test being run is a timeseries test

View File

@ -610,8 +610,9 @@ buildvariants:
expansions:
<<: *enterprise-rhel-8-64-bit-dynamic-expansions
# JS_GC_ZEAL modes can be found at https://github.com/mongodb/mongo/blob/r8.0.0-rc9/src/third_party/mozjs/extract/js/src/gc/GC.cpp#L563-L612.
# These modes correspond to collecting the nursery (GenerationalGC) every 50 allocations.
mozjs_options: JS_GC_ZEAL='7,50'
# These modes correspond to a GC policy of generationalGC (mode 7) every 75 allocations, and a
# consistency check of the heap after every GC cycle (mode 15).
mongo_mozjs_options: "7;15,75"
compile_flags: >-
--ssl
MONGO_DISTMOD=rhel88
@ -623,6 +624,8 @@ buildvariants:
compile_variant: enterprise-rhel-8-64-bit-dynamic-spider-monkey-dbg
exec_timeout_secs: 32400 # 9 hour timeout
timeout_secs: 18000 # 5 hour idle timeout
test_flags: >-
--includeWithAnyTags=requires_scripting
depends_on: []
tasks:
- name: compile_test_parallel_core_stream_TG
@ -630,5 +633,8 @@ buildvariants:
- rhel8.8-xlarge
- name: aggregation
- name: aggregation_mongos_passthrough
- name: auth_gen
- name: concurrency_simultaneous_gen
- name: jsCore
- name: noPassthrough_gen
- name: sharding_gen

5
evergreen/resmoke_tests_execute.sh Normal file → Executable file
View File

@ -117,6 +117,11 @@ if [[ ${disable_unit_tests} = "false" && ! -f ${skip_tests} ]]; then
extra_args="$extra_args --runNoFeatureFlagTests"
fi
# Introduce JS_GC_ZEAL to be used specifically under mongod/mongos.
if [[ "${build_variant}" = "enterprise-rhel-8-64-bit-dynamic-spider-monkey-dbg" && ! -z "${mongo_mozjs_options}" ]]; then
extra_args="$extra_args --mozjsJsGcZeal='${mongo_mozjs_options}'"
fi
path_value="$PATH:/data/multiversion"
# Set the suite name to be the task name by default; unless overridden with the `suite` expansion.

View File

@ -9,6 +9,8 @@
* requires_auth,
* requires_replication,
* requires_sharding,
* # Uses $function
* requires_scripting,
* uses_transactions,
* featureFlagSecurityToken,
* ]

View File

@ -6,7 +6,7 @@
* The test logic implemented here operates on the test cases defined
* in jstests/auth/lib/commands_lib.js
*
* @tags: [requires_sharding]
* @tags: [requires_sharding, requires_scripting]
*/
import {runAllCommandsBuiltinRoles} from "jstests/auth/lib/commands_builtin_roles.js";

View File

@ -5,6 +5,9 @@
*
* The test logic implemented here operates on the test cases defined
* in jstests/auth/lib/commands_lib.js
* @tags: [
* requires_scripting
* ]
*/
import {runAllCommandsBuiltinRoles} from "jstests/auth/lib/commands_builtin_roles.js";

View File

@ -5,7 +5,7 @@ Exhaustive test for authorization of commands with user-defined roles.
The test logic implemented here operates on the test cases defined
in jstests/auth/lib/commands_lib.js.
@tags: [requires_sharding]
@tags: [requires_sharding, requires_scripting]
*/

View File

@ -8,6 +8,7 @@
* # Transactions aborted upon fcv upgrade or downgrade; cluster parameters use internal txns.
* uses_transactions,
* requires_fcv_80,
* requires_scripting,
* ]
*/

View File

@ -9,6 +9,7 @@
* # Transactions aborted upon fcv upgrade or downgrade; cluster parameters use internal txns.
* uses_transactions,
* requires_fcv_80,
* requires_scripting,
* ]
*/

View File

@ -9,6 +9,7 @@
* required_auth,
* requires_sharding,
* uses_transactions,
* requires_scripting,
* ]
*/

View File

@ -8,6 +8,7 @@
* required_auth,
* requires_sharding,
* uses_transactions,
* requires_scripting,
* ]
*/
import {configureFailPoint} from "jstests/libs/fail_point_util.js";

View File

@ -1,3 +1,8 @@
/**
* @tags: [
* requires_scripting
* ]
*/
// Test for SERVER-9129
// Verify global scope data does not persist past logout or auth.
// NOTE: Each test case covers 3 state transitions:

View File

@ -2,7 +2,7 @@
// mode. Other modes require writing to an output collection which is not allowed. SERVER-3345
//
// This test requires users to persist across a restart.
// @tags: [requires_persistence]
// @tags: [requires_persistence, requires_scripting]
let baseName = "jstests_mr_auth";
let dbName = "test";

View File

@ -1,3 +1,10 @@
/**
* @tags: [
* # Uses $where operator
* requires_scripting,
* ]
*/
/**
* Verify that killing an instance of mongod while it is in a long running computation or infinite
* loop still leads to clean shutdown, and that said shutdown is prompt.

View File

@ -1,5 +1,9 @@
/**
* Test that verifies client metadata is logged as part of slow query logging in MongoD.
*
* @tags: [
* requires_scripting
* ]
*/
let conn = MongoRunner.runMongod({useLogFiles: true});
assert.neq(null, conn, 'mongod was unable to start up');
@ -29,4 +33,4 @@ for (var a of log.split("\n")) {
assert(predicate.test(log),
"'Slow query' log line missing in mongod log file!\n" +
"Log file contents: " + conn.fullOptions.logFile);
MongoRunner.stopMongod(conn);
MongoRunner.stopMongod(conn);

View File

@ -3,6 +3,7 @@
* set.
* @tags: [
* requires_replication,
* requires_scripting,
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
@ -47,4 +48,4 @@ count = coll.find({
assert.eq(count.length, 1, "expected 1 document");
assert(checkLog.checkContainsOnce(rst.getSecondary(), predicate));
rst.stopSet();
rst.stopSet();

View File

@ -5,6 +5,7 @@
* requires_persistence,
* requires_replication,
* requires_sharding,
* requires_scripting,
* ]
*/

View File

@ -4,6 +4,7 @@
* @tags: [
* requires_replication,
* requires_sharding,
* requires_scripting,
* ]
*/
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";

View File

@ -4,6 +4,7 @@
// We want to make sure that the deprecation warning message is only logged twice despite
// the multiple invocations in an effort to not clutter the dev's console.
// More specifically, we expect to only log 1 out of 128 events.
// @tags: [requires_scripting]
import {iterateMatchingLogLines} from "jstests/libs/log.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
@ -202,4 +203,4 @@ deprecationTest(shardedDB, accumulatorDeprecationMsg, accumulatorCmdObj, shards)
deprecationTest(shardedDB, functionDeprecationMsg, functionAggCmdObj, shards);
deprecationTest(shardedDB, functionDeprecationMsg, functionFindCmdObj, shards);
shards.stop();
shards.stop();

View File

@ -1,5 +1,8 @@
/**
* Tests for validating that optimization stats are included in explain output.
* @tags: [
* requires_scripting
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -1,5 +1,8 @@
/**
* Tests where/function can be interrupted through maxTimeMS and query knob.
* @tags: [
* requires_scripting
* ]
*/
const mongodOptions = {};
const conn = MongoRunner.runMongod(mongodOptions);
@ -75,4 +78,4 @@ tests.forEach(function(testCase) {
testCase.err(cursor);
});
MongoRunner.stopMongod(conn);
MongoRunner.stopMongod(conn);

View File

@ -1,5 +1,6 @@
// Test partial indexes with commands that don't use explain. These commands are tested against
// mongod with the --notablescan flag set, so that they fail if the index is not used.
// @tags: [requires_scripting]
import {resultsEq} from "jstests/aggregation/extras/utils.js";
var runner = MongoRunner.runMongod({setParameter: "notablescan=1"});

View File

@ -1,3 +1,8 @@
/*
* @tags: [
* requires_scripting,
* ]
*/
import {
testGetCmdLineOptsMongod,
testGetCmdLineOptsMongos

View File

@ -8,6 +8,10 @@
* server.
* 3. db.loadServerScripts performs as expected even with the flag is set in
* the shell.
*
* @tags: [
* requires_scripting
* ]
*/
var testServer = MongoRunner.runMongod({setParameter: "javascriptProtection=true"});

View File

@ -3,6 +3,7 @@
* listCollection and listIndexes commands can run while a MODE_X collection lock is held.
*
* @tags: [
* requires_scripting,
* ]
*/
@ -95,4 +96,4 @@ jsTestLog("Waiting for unstalled collMod operation to finish.");
awaitBlockingCollMod();
jsTestLog("Done.");
MongoRunner.stopMongod(conn);
MongoRunner.stopMongod(conn);

View File

@ -4,6 +4,7 @@
* @tags: [
* requires_replication,
* requires_sharding,
* requires_scripting,
* ]
*/

View File

@ -1,6 +1,6 @@
/**
* This test verifies the correctness of the "nReturned" value output in the slow query logs.
* @tags: []
* @tags: [requires_scripting]
*/
import {findMatchingLogLine} from "jstests/libs/log.js";

View File

@ -4,6 +4,7 @@
* Creates a sharded cluster.
* @tags: [
* requires_sharding,
* requires_scripting,
* ]
*/
import {FixtureHelpers} from "jstests/libs/fixture_helpers.js";

View File

@ -1,7 +1,7 @@
// Tests that if a mongoS cursor exceeds the maxTimeMs timeout, the cursors on the shards will be
// cleaned up. Exercises the fix for the bug described in SERVER-62710.
//
// @tags: []
// @tags: [requires_scripting]
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -1,5 +1,9 @@
// Test mapReduce use with different values of the allowDiskUseByDefault parameter.
/**
* Test mapReduce use with different values of the allowDiskUseByDefault parameter.
* @tags: [
* requires_scripting,
* ]
*/
const conn = MongoRunner.runMongod();
assert.neq(null, conn, "mongod was unable to start up");
@ -36,4 +40,4 @@ assert.commandWorked(db.adminCommand({setParameter: 1, allowDiskUseByDefault: tr
const res = assert.commandWorked(db.runCommand(mapReduceCmd));
assert.eq(res.results[0], {_id: "a", value: 42}, res);
MongoRunner.stopMongod(conn);
MongoRunner.stopMongod(conn);

View File

@ -1,6 +1,7 @@
// See SERVER-9448
// Test argument and receiver (aka 'this') objects and their children can be mutated
// in Map, Reduce and Finalize functions
// @tags: [requires_scripting]
import {assertArrayEq} from "jstests/aggregation/extras/utils.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
@ -94,4 +95,4 @@ let st = new ShardingTest({shards: 2, setParameter: {mrEnableSingleReduceOptimiz
assert.neq(null, st.s, "mongod was unable to start up");
st.s.adminCommand({shardCollection: "test.mrMutableReceiver"});
runTest(st.s.getDB("test").mrMutableReceiver);
st.stop();
st.stop();

View File

@ -1,5 +1,6 @@
// See SERVER-68766. Verify that the reduce function is not run on a single value if the relevant
// flag is enabled.
// @tags: [requires_scripting]
const conn = MongoRunner.runMongod({setParameter: {mrEnableSingleReduceOptimization: true}});
const testDB = conn.getDB('foo');

View File

@ -1,6 +1,6 @@
/**
* Tests counters for match expressions.
* @tags: [requires_fcv_50]
* @tags: [requires_fcv_50, requires_scripting]
*/
const mongod = MongoRunner.runMongod();
@ -283,4 +283,4 @@ checkCounters(
.itcount()),
"$geoIntersects");
MongoRunner.stopMongod(mongod);
MongoRunner.stopMongod(mongod);

View File

@ -3,6 +3,7 @@
*
* @tags: [
* requires_profiling,
* requires_scripting,
* ]
*/
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";

View File

@ -4,7 +4,7 @@
* state, the collection can still be successfully created on the fly.
*
* This test restarts the server and requires that data persists across restarts.
* @tags: [requires_persistence, requires_profiling]
* @tags: [requires_persistence, requires_profiling, requires_scripting]
*/
//
// Start mongo with profiling disabled, create an empty database, and populate it with a
@ -53,4 +53,4 @@ const res = db.runCommand({listCollections: 1, filter: {name: "system.profile"}}
assert.commandWorked(res);
assert.eq(res.cursor.firstBatch.length, 1, res);
MongoRunner.stopMongod(standalone);
MongoRunner.stopMongod(standalone);

View File

@ -6,7 +6,8 @@
* 'ephemeralForTest' storage engines that do not support queryable backup (read-only) mode.
* @tags: [
* requires_persistence,
* requires_replication
* requires_replication,
* requires_scripting
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";

View File

@ -1,5 +1,8 @@
/**
* Tests for the command assertion functions in mongo/shell/assert.js.
* @tags: [
* requires_scripting,
* ]
*/
const conn = MongoRunner.runMongod();
@ -406,4 +409,4 @@ tests.forEach((test) => {
});
/* cleanup */
MongoRunner.stopMongod(conn);
MongoRunner.stopMongod(conn);

View File

@ -12,7 +12,8 @@
// due to client disconnect, and the number of completed operations that couldn't return data
// due to client disconnect.
//
// @tags: [requires_sharding]
// @tags: [requires_sharding, requires_scripting]
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -6,6 +6,7 @@
* which cannot support a replica set.
* @tags: [
* requires_replication,
* requires_scripting
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
@ -284,4 +285,4 @@ for (let result of results) {
assert.eq(result.mergeCT, result.aggCT);
}
rst.stopSet();
rst.stopSet();

View File

@ -6,6 +6,7 @@
* cannot support a sharded cluster.
* @tags: [
* requires_sharding,
* requires_scripting
* ]
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";
@ -308,4 +309,4 @@ for (let result of results) {
assert.eq(result.mergeCT, result.aggCT);
}
st.stop();
st.stop();

View File

@ -1,3 +1,8 @@
/**
* @tags: [
* requires_scripting
* ]
*/
var db;
const conn = MongoRunner.runMongod();
assert.neq(null, conn, "mongod failed to start.");

View File

@ -4,6 +4,10 @@
* defines various database commands and what they expect to be true before and after the fact.
* It then runs the commands with an invalid writeConcern and a valid writeConcern and
* ensures that they succeed and fail appropriately.
*
* @tags: [
* requires_scripting,
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
@ -197,4 +201,4 @@ commands.forEach(function(cmd) {
testInvalidWriteConcern(cmd);
});
replTest.stopSet();
replTest.stopSet();

View File

@ -1,3 +1,8 @@
/**
* @tags: [
* requires_scripting
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
import {waitForAllMembers} from "jstests/replsets/rslib.js";

View File

@ -6,6 +6,7 @@
// We verify this requirement by running a map-reduce, examining the logs to find the names of
// all collections created, and checking the oplog for entries logging the creation of each of those
// collections.
// @tags: [requires_scripting]
import {ReplSetTest} from "jstests/libs/replsettest.js";

View File

@ -22,6 +22,7 @@
* uses_transactions,
* # TODO (SERVER-80568): Re-enable this test in multiversion suites once it has been fixed.
* DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE,
* requires_scripting
* ]
*/

View File

@ -25,7 +25,7 @@
* us to keep more tests running now. That said, these should ideally all throw so we do not rely on
* the test itself calling assert.commandWorked.
*
* @tags: [requires_replication, uses_transactions]
* @tags: [requires_replication, uses_transactions, requires_scripting]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";

View File

@ -1,6 +1,10 @@
/**
* Tests update with $where does not wait for write concern (which would trigger assertion while
* holding global lock) when it iterates system.js collection using DBDirectClient.
*
* @tags: [
* requires_scripting
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";

View File

@ -11,6 +11,7 @@
* requires_replication,
* requires_getmore,
* requires_fcv_62,
* requires_scripting
* ]
*/
import {configureFailPoint} from "jstests/libs/fail_point_util.js";

View File

@ -9,6 +9,7 @@
* # TODO (SERVER-88123): Re-enable this test.
* # Test doesn't start enough mongods to have num_mongos routers
* embedded_router_incompatible,
* requires_scripting
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";

View File

@ -1,6 +1,6 @@
/**
* This tests using DB commands with authentication enabled when sharded.
* @tags: [multiversion_incompatible]
* @tags: [multiversion_incompatible, requires_scripting]
*/
// Multiple users cannot be authenticated on one connection within a session.
TestData.disableImplicitSessions = true;

View File

@ -9,6 +9,7 @@
* of 5MB across all sharding tests in wiredTiger.
* @tags: [
* resource_intensive,
* requires_scripting
* ]
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -8,6 +8,7 @@
* # TODO (SERVER-88123): Re-enable this test.
* # Test doesn't start enough mongods to have num_mongos routers
* embedded_router_incompatible,
* requires_scripting
* ]
*/

View File

@ -1,3 +1,4 @@
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
var s = new ShardingTest({shards: 2, mongos: 1});

View File

@ -7,6 +7,7 @@
// - Tests fsync and fsync+lock permissions on sharded db
// @tags: [
// expects_explicit_underscore_id_index,
// requires_scripting
// ]
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -9,6 +9,7 @@
* # This test is known to be racey due to implementation of hedged reads (SERVER-65329).
* # Disable windows testing as this feature is deprecated in v8.0.
* incompatible_with_windows_tls,
* requires_scripting
* ]
*/
import {configureFailPoint} from "jstests/libs/fail_point_util.js";

View File

@ -9,6 +9,7 @@ import {ShardingTest} from "jstests/libs/shardingtest.js";
// The following checks, which occurs on ShardingTest.stop, involve using a mongos to read data on
// the config server, but this test uses a special shutdown function which stops the mongoses before
// calling ShardingTest.stop.
// @tags : [requires_scripting]
TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
TestData.skipCheckingIndexesConsistentAcrossCluster = true;
TestData.skipCheckOrphans = true;

View File

@ -1,5 +1,5 @@
/**
* @tags: [does_not_support_stepdowns]
* @tags: [does_not_support_stepdowns, requires_scripting]
*/
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {FixtureHelpers} from "jstests/libs/fixture_helpers.js";

View File

@ -1,5 +1,6 @@
// Test that map reduce and aggregate properly handle shard versioning.
// Test delibarately inserts orphaned data outside of migrations.
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
TestData.skipCheckOrphans = true;
@ -57,4 +58,4 @@ res = staleMongos2.getCollection(nsString).aggregate(
[{$group: {_id: "$key", value: {$sum: "$value"}}}, {$sort: {_id: 1}}]);
validateOutput(res.toArray());
st.stop();
st.stop();

View File

@ -3,6 +3,7 @@
* cluster when there are documents on multiple chunks that need to be merged.
* @tags: [
* backport_required_multiversion,
* requires_scripting
* ]
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";
@ -52,4 +53,4 @@ res = assert.commandWorked(mongosDB.runCommand(
{mapReduce: mongosColl.getName(), map: map, reduce: reduce, out: {inline: 1}}));
assert.eq(res.results[0], {_id: 0, value: {val: "reduced value"}});
st.stop();
st.stop();

View File

@ -1,5 +1,6 @@
// Performs an aggregation that will execute JavaScript on mongos. This is a sanity check to confirm
// that JavaScript is available on mongos.
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -1,4 +1,5 @@
// Test shard targeting for queries with collation.
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
import {
WriteWithoutShardKeyTestUtil
@ -527,4 +528,4 @@ explain = coll.explain().update(
assert.commandWorked(explain);
assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
st.stop();
st.stop();

View File

@ -1,4 +1,5 @@
// Test shard targeting for queries on a collection with a default collation.
// @tags : [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
import {
WriteWithoutShardKeyTestUtil
@ -556,4 +557,4 @@ explain =
assert.commandWorked(explain);
assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
st.stop();
st.stop();

View File

@ -3,6 +3,9 @@
*
* Always run on a fully upgraded cluster, so that {$meta: "sortKey"} projections use the newest
* sort key format.
* @tags: [
* requires_scripting,
* ]
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";
@ -158,4 +161,4 @@ assert.eq(cmdRes.cursor.firstBatch[3], {key: [1]});
assert.eq(cmdRes.cursor.firstBatch[4], {key: [5]});
assert.eq(cmdRes.cursor.firstBatch[5], {key: [9]});
st.stop();
st.stop();

View File

@ -1,3 +1,9 @@
/**
* @tags: [
* requires_scripting
* ]
*/
// Confirms that JavaScript heap limits are respected in aggregation. Includes testing for mapReduce
// and $where which use aggregation for execution.
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -1,5 +1,6 @@
// Test that mapReduce correctly fails if the target collection is not unsharded or sharded by just
// _id.
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
const st = new ShardingTest({shards: 2, mongos: 2});
@ -124,4 +125,4 @@ testAgainstValidShardedOutput({_id: "hashed"});
31313);
})();
st.stop();
st.stop();

View File

@ -4,6 +4,7 @@
// # TODO (SERVER-88127): Re-enable this test or add an explanation why it is incompatible.
// embedded_router_incompatible,
// uses_map_reduce_with_temp_collections,
// requires_scripting
// ]
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -1,6 +1,9 @@
/**
* Test to verify 'scope' parameter of mapReduce command. This test verfies that 'map', 'reduce' and
* 'finalize' functions can use 'scope' variable passed in the input.
* @tags: [
* requires_scripting,
* ]
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -2,6 +2,7 @@
// flag.
// This test stresses behavior that is only true of the mapReduce implementation using aggregation,
// so it cannot be run in mixed-version suites.
// @tags: [requires_scripting]
import {FixtureHelpers} from "jstests/libs/fixture_helpers.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -1,6 +1,9 @@
/**
* Test that a mapReduce job can write sharded output to a database
* from a separate input database while authenticated to both.
* @tags: [
* requires_scripting,
* ]
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -1,5 +1,6 @@
// Tests that the mapReduce command works correctly under all combinations of the input and output
// collections being sharded or unsharded.
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
const st = new ShardingTest({shards: 2, other: {chunkSize: 1}});
@ -102,4 +103,4 @@ output = inputColl.mapReduce(
assert.commandWorked(output);
assert.eq(output.results, [{_id: 0, value: 1}]);
st.stop();
st.stop();

View File

@ -1,4 +1,5 @@
// Test MapReduce output option replace into different db in a sharded environment.
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
const st = new ShardingTest({shards: 2, mongos: 1});
@ -66,4 +67,4 @@ assert.eq(2, destColl.find().count(), result);
const finalIndexes = assert.commandWorked(destDB.runCommand({"listIndexes": destColl.getName()}));
const finalIndexesArray = new DBCommandCursor(destDB, finalIndexes).toArray();
assert.eq(2, finalIndexesArray.length);
st.stop();
st.stop();

View File

@ -2,6 +2,7 @@
// @tags: [
// # TODO (SERVER-88122): Re-enable this test or add an explanation why it is incompatible.
// embedded_router_incompatible,
// requires_scripting,
// ]
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -5,6 +5,7 @@
* resource_intensive,
* # TODO (SERVER-88127): Re-enable this test or add an explanation why it is incompatible.
* embedded_router_incompatible,
* requires_scripting
* ]
*/
import {configureFailPoint} from "jstests/libs/fail_point_util.js";

View File

@ -25,6 +25,7 @@
* @tags: [
* # TODO (SERVER-88125): Re-enable this test or add an explanation why it is incompatible.
* embedded_router_incompatible,
* requires_scripting,
* ]
*/
import {

View File

@ -18,6 +18,7 @@
* @tags: [
* # TODO (SERVER-88125): Re-enable this test or add an explanation why it is incompatible.
* embedded_router_incompatible,
* requires_scripting,
* ]
*/
import {

View File

@ -3,6 +3,7 @@
// If the optional query is not given, mongos will wrongly use the command
// BSONObj itself as the query to target shards, which could return wrong
// shards if the shard key happens to be one of the fields in the command object.
// @tags: [requires_scripting]
import {ShardingTest} from "jstests/libs/shardingtest.js";
var s = new ShardingTest({shards: 2});

View File

@ -40,6 +40,13 @@ if jsEngine:
)
scriptingEnv.InjectMozJS()
if get_option("spider-monkey-dbg") == "on":
scriptingEnv.Prepend(
CPPDEFINES=[
"MONGO_SPIDERMONKEY_DBG",
]
)
scriptingEnv.Library(
target="scripting",
source=[

View File

@ -556,6 +556,12 @@ MozJSImplScope::MozJSImplScope(MozJSScriptEngine* engine, boost::optional<int> j
_engine->getScopeInitCallback()(*this);
}
#ifdef MONGO_SPIDERMONKEY_DBG
if (const auto* jsGcZealEnv = getenv("JS_GC_ZEAL"); jsGcZealEnv) {
LOGV2_INFO(9202400, "Initializing MozJSImplScope", "jsGcZeal"_attr = jsGcZealEnv);
}
#endif
currentJSScope = this;
}
@ -1167,6 +1173,12 @@ bool MozJSImplScope::_checkErrorState(bool success, bool reportError, bool asser
if (_status.isOK()) {
JS::RootedValue excn(_context);
if (JS_GetPendingException(_context, &excn)) {
// It's possible that we have an uncaught exception for OOM, which is reported on the
// exception status of the JSContext. We must check for this OOM exception before
// clearing the pending exception. This function checks both the status on the JSContext
// as well as the message string of the exception being provided.
const auto isThrowingOOM = JS_IsThrowingOutOfMemoryException(_context, excn);
// The pending JS exception needs to be cleared before we call ValueWriter below to
// print the exception. ValueWriter::toStringData() may call back into the Interpret,
// which asserts that we don't have an exception pending in DEBUG builds.
@ -1207,10 +1219,15 @@ bool MozJSImplScope::_checkErrorState(bool success, bool reportError, bool asser
} else {
str::stream ss;
JSStringWrapper jsstr;
ss << "uncaught exception: "
<< str::UTF8SafeTruncation(ValueWriter(_context, excn).toStringData(&jsstr),
kMaxErrorStringSize);
_status = Status(ErrorCodes::UnknownError, ss);
if (isThrowingOOM) {
_status = Status(ErrorCodes::JSInterpreterFailure, "Out of memory");
} else {
ss << "uncaught exception: "
<< str::UTF8SafeTruncation(ValueWriter(_context, excn).toStringData(&jsstr),
kMaxErrorStringSize);
_status = Status(ErrorCodes::UnknownError, ss);
}
}
} else {
_status = Status(ErrorCodes::UnknownError, "Unknown Failure from JSInterpreter");
@ -1255,7 +1272,7 @@ MozJSImplScope* MozJSImplScope::getThreadScope() {
void MozJSImplScope::setOOM() {
_hasOutOfMemoryException = true;
JS_RequestInterruptCallback(_context);
JS_RequestInterruptCallbackCanWait(_context);
}
void MozJSImplScope::setParentStack(std::string parentStack) {

View File

@ -115,11 +115,20 @@ void* wrap_alloc(T&& func, void* ptr, size_t bytes) {
size_t mb = get_max_bytes();
size_t tb = get_total_bytes();
if (mb && (tb + bytes > mb)) {
// During a GC cycle, GC::purgeRuntime() is called, which tries to free unused items in the
// SharedImmutableStringsCache while holding its corresponding mutex. Our js_free implementation
// calls wrap_alloc, with a value of 0 for 'bytes'. Previously, if we were already at the
// max_bytes limit when purging the runtime, the call to MozJSImplScope::setOOM() would request
// an urgent JS interrupt, which acquires a futex with order 500, while still holding the mutex
// for the SharedImmutableStringsCache (order 600). This triggered a failure of a MOZ_ASSERT
// which enforces correct lock ordering in the JS engine. For this reason, we avoid checking
// for an OOM here if we are requesting zero bytes (i.e freeing memory).
if (mb && bytes && (tb + bytes > mb)) {
auto scope = mongo::mozjs::MozJSImplScope::getThreadScope();
if (scope)
if (scope) {
scope->setOOM();
return nullptr;
}
// We fall through here because we want to let spidermonkey continue
// with whatever it was doing. Calling setOOM will fail the top level
// operation as soon as possible.

View File

@ -1599,6 +1599,14 @@ MongoRunner._startWithArgs = function(argArray, env, waitForConnect) {
argArray = appendSetParameterArgs(argArray);
var port = MongoRunner.parsePort.apply(null, argArray);
var pid = -1;
if (jsTest.options().mozJSGCZeal) {
if (env === undefined) {
env = {};
}
env["JS_GC_ZEAL"] = jsTest.options().mozJSGCZeal;
}
if (env === undefined) {
pid = _startMongoProgram.apply(null, argArray);
} else {

View File

@ -526,6 +526,7 @@ jsTestOptions = function() {
performTimeseriesCompressionIntermediateDataIntegrityCheckOnInsert: true,
fuzzMongodConfigs: TestData.fuzzMongodConfigs || false,
mozJSGCZeal: TestData.mozJSGCZeal || "",
});
}
return _jsTestOptions;

View File

@ -42,6 +42,10 @@ extern JS_PUBLIC_API void JS_SetPendingException(
extern JS_PUBLIC_API void JS_ClearPendingException(JSContext* cx);
// MONGODB MODIFICATION: Checks if we are currently throwing an OOM exception and the exception
// message matches the out of memory exception string.
extern JS_PUBLIC_API bool JS_IsThrowingOutOfMemoryException(JSContext* cx, const JS::Value& exc);
/**
* If the given object is an exception object, the exception will have (or be
* able to lazily create) an error report struct, and this function will return

View File

@ -3779,6 +3779,12 @@ JS_PUBLIC_API void JS_ClearPendingException(JSContext* cx) {
cx->clearPendingException();
}
// MONGODB MODIFICATION: Checks if we are currently throwing an OOM exception and the exception
// message matches the out of memory exception string.
JS_PUBLIC_API bool JS_IsThrowingOutOfMemoryException(JSContext* cx, const JS::Value& exc) {
return cx->isThrowingOutOfMemoryException(exc);
}
JS::AutoSaveExceptionState::AutoSaveExceptionState(JSContext* cx)
: context(cx), status(cx->status), exceptionValue(cx), exceptionStack(cx) {
AssertHeapIsIdle();

View File

@ -1114,11 +1114,23 @@ void JSContext::setRuntime(JSRuntime* rt) {
runtime_ = rt;
}
#if defined(NIGHTLY_BUILD)
// MONGODB MODIFICATION: This function is required to check for OOM exceptions which are thrown as a
// JSString instead of JSObject, which makes it difficult to compare against ErrorNumbers directly.
// Instead, we have to compare the message string obtained from the exception against the expected
// value.
static bool IsOutOfMemoryException(JSContext* cx, const Value& v) {
return v == StringValue(cx->names().outOfMemory);
}
#endif
// MONGODB MODIFICATION:
// When an OOM exception is thrown by SpiderMonkey (see https://github.com/10gen/mongo/blob/master/src/third_party/mozjs/extract/js/src/vm/JSContext.cpp#L270),
// the exception status is set to ExceptionStatus::OutOfMemory and the exception is generated as a
// JSString using the message in ErrorNumbers.msg. By checking for both these conditions, we can
// detect whether or not the exception we are handling is an out of memory exception thrown by
// SpiderMonkey.
bool JSContext::isThrowingOutOfMemoryException(const Value& exc) {
return isThrowingOutOfMemory() && IsOutOfMemoryException(this, exc);
}
void JSContext::setPendingException(HandleValue v, Handle<SavedFrame*> stack) {
#if defined(NIGHTLY_BUILD)

View File

@ -286,6 +286,10 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext,
JS::NativeStackLimit stackLimitForJitCode(JS::StackKind kind);
size_t gcSystemPageSize() { return js::gc::SystemPageSize(); }
// MONGODB MODIFICATION: Checks if we are currently throwing an OOM exception and the exception
// message matches the out of memory exception string.
bool isThrowingOutOfMemoryException(const JS::Value& exc);
/*
* "Entering" a realm changes cx->realm (which changes cx->global). Note
* that this does not push an Activation so it's possible for the caller's

View File

@ -10,7 +10,7 @@ NAME=spidermonkey
VERSION="115.7.0esr"
LIB_GIT_BRANCH=spidermonkey-esr115.7-cpp-only
LIB_GIT_REVISION=e696addae6303fddfe1128f8d6090130bb68d61d
LIB_GIT_REVISION=bd739211fb34733b254407d78788a24b206ab99d
LIB_GIT_REPO=git@github.com:mongodb-forks/spidermonkey.git
DEST_DIR=$(git rev-parse --show-toplevel)/src/third_party/mozjs

View File

@ -42,6 +42,10 @@ extern JS_PUBLIC_API void JS_SetPendingException(
extern JS_PUBLIC_API void JS_ClearPendingException(JSContext* cx);
// MONGODB MODIFICATION: Checks if we are currently throwing an OOM exception and the exception
// message matches the out of memory exception string.
extern JS_PUBLIC_API bool JS_IsThrowingOutOfMemoryException(JSContext* cx, const JS::Value& exc);
/**
* If the given object is an exception object, the exception will have (or be
* able to lazily create) an error report struct, and this function will return