Files
mongo/jstests/core/query/recursion.js
Mihai Andrei 05a9f6fe33 SERVER-92931 Move query jstests into 'query' subdirectories (#25775)
GitOrigin-RevId: ea87222af5d2e8528c723533b7afa121cd3b22fa
2024-09-07 03:01:57 +00:00

36 lines
1.1 KiB
JavaScript

// Basic tests for a form of stack recursion that's been shown to cause C++ side stack overflows in
// the past. See SERVER-19614.
//
// @tags: [
// # The test runs commands that are not allowed with security token: mapReduce.
// not_allowed_with_signed_security_token,
// does_not_support_stepdowns,
// requires_non_retryable_commands,
// uses_map_reduce_with_temp_collections,
// # This test has statements that do not support non-local read concern.
// does_not_support_causal_consistency,
// ]
db.recursion.drop();
// Make sure the shell doesn't blow up.
function shellRecursion() {
shellRecursion.apply();
}
assert.throws(shellRecursion);
// Make sure server side stack overflow doesn't blow up.
function mapReduceRecursion() {
db.recursion.mapReduce(
function() {
(function recursion() {
recursion.apply();
})();
},
function() {},
{out: {merge: 'out_coll'}});
}
assert.commandWorked(db.recursion.insert({}));
assert.commandFailedWithCode(assert.throws(mapReduceRecursion), ErrorCodes.JSInterpreterFailure);