diff options
author | David Percy <david.percy@mongodb.com> | 2021-05-24 21:00:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-26 16:04:14 +0000 |
commit | 2f4c2c6bdca301934d32a9f3a1f6fc76946f7b11 (patch) | |
tree | 1bee00cedf7e29ec5ad52554a58f40fc9b3a4847 /jstests/aggregation | |
parent | c9c9efbde4fbb3d9e6f0def1ae97a8e27d15ef41 (diff) | |
download | mongo-2f4c2c6bdca301934d32a9f3a1f6fc76946f7b11.tar.gz |
SERVER-57164 isVariableReference includes system variables
This fixes an invariant failure in DocumentSourceGroup.
Diffstat (limited to 'jstests/aggregation')
-rw-r--r-- | jstests/aggregation/sources/group/group_by_system_variable.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/jstests/aggregation/sources/group/group_by_system_variable.js b/jstests/aggregation/sources/group/group_by_system_variable.js new file mode 100644 index 00000000000..6c223343166 --- /dev/null +++ b/jstests/aggregation/sources/group/group_by_system_variable.js @@ -0,0 +1,27 @@ +/* + * Tests that the server doesn't crash when you group by a system variable. + * Reproduces SERVER-57164. + */ +(function() { +"use strict"; + +const coll = db.group_by_system_variable; +coll.drop(); +assert.commandWorked(coll.insert({})); + +// These explains all should not throw. +coll.explain().aggregate({$group: {_id: "$$IS_MR"}}); +coll.explain().aggregate({$group: {_id: "$$JS_SCOPE"}}); +coll.explain().aggregate({$group: {_id: "$$CLUSTER_TIME"}}); + +// These queries throw, but the server should stay up. +assert.throws(() => coll.aggregate({$group: {_id: "$$IS_MR"}})); +assert.throws(() => coll.aggregate({$group: {_id: "$$JS_SCOPE"}})); +try { + // This one may or may not throw: CLUSTER_TIME may or may not be defined, + // depending on what kind of cluster we're running against. + coll.aggregate({$group: {_id: "$$CLUSTER_TIME"}}); +} catch (e) { +} +db.hello(); +})(); |