2018-01-30 19:45:42 -05:00
|
|
|
// 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: [
|
2023-08-23 16:07:27 +00:00
|
|
|
// # The test runs commands that are not allowed with security token: mapReduce.
|
2023-12-11 22:44:46 +00:00
|
|
|
// not_allowed_with_signed_security_token,
|
2018-01-30 19:45:42 -05:00
|
|
|
// does_not_support_stepdowns,
|
|
|
|
|
// requires_non_retryable_commands,
|
2019-08-20 15:32:40 +00:00
|
|
|
// uses_map_reduce_with_temp_collections,
|
2022-05-27 14:40:28 +00:00
|
|
|
// # This test has statements that do not support non-local read concern.
|
|
|
|
|
// does_not_support_causal_consistency,
|
2025-08-21 11:45:11 +02:00
|
|
|
// requires_scripting,
|
2025-11-21 12:33:41 -05:00
|
|
|
// # Time-series collections are views which don't support map-reduce
|
|
|
|
|
// exclude_from_timeseries_crud_passthrough,
|
2018-01-30 19:45:42 -05:00
|
|
|
// ]
|
2015-09-25 15:34:18 -04:00
|
|
|
|
2015-10-26 13:02:08 -04:00
|
|
|
db.recursion.drop();
|
|
|
|
|
|
2019-10-29 16:56:38 +00:00
|
|
|
// Make sure the shell doesn't blow up.
|
2015-10-26 13:02:08 -04:00
|
|
|
function shellRecursion() {
|
|
|
|
|
shellRecursion.apply();
|
|
|
|
|
}
|
|
|
|
|
assert.throws(shellRecursion);
|
|
|
|
|
|
2019-10-29 16:56:38 +00:00
|
|
|
// Make sure server side stack overflow doesn't blow up.
|
2015-10-26 13:02:08 -04:00
|
|
|
function mapReduceRecursion() {
|
2016-03-09 12:17:50 -05:00
|
|
|
db.recursion.mapReduce(
|
2025-08-21 10:17:44 -07:00
|
|
|
function () {
|
2016-03-09 12:17:50 -05:00
|
|
|
(function recursion() {
|
|
|
|
|
recursion.apply();
|
|
|
|
|
})();
|
|
|
|
|
},
|
2025-08-21 10:17:44 -07:00
|
|
|
function () {},
|
|
|
|
|
{out: {merge: "out_coll"}},
|
|
|
|
|
);
|
2015-10-26 13:02:08 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-29 16:56:38 +00:00
|
|
|
assert.commandWorked(db.recursion.insert({}));
|
2023-08-23 16:07:27 +00:00
|
|
|
assert.commandFailedWithCode(assert.throws(mapReduceRecursion), ErrorCodes.JSInterpreterFailure);
|