Operational Defect Database

BugZero found this defect 60 days ago.

MongoDB | 2614864

$group constant expression fails to re-parse

Last update date:

3/20/2024

Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

No fixed releases provided.

Description:

Info

Tripwire assertion error: {'code': 7349401, 'codeName': 'Location7349401', 'errmsg': 'Was not able to re-parse queryStats key when reading queryStats.Status Location17390: $group does not support inclusion-style expressions Hash: 1070139331129839062 Query Shape: { cmdNs: { db: "test", coll: "jstests_indexu_NaN" }, command: "aggregate", pipeline: [ { $group: { _id: { by: 1 }, count: { $sum: 1 } } }, { $sort: { count: -1 } } ] }'} location: {fileName:"src/mongo/db/pipeline/document_source_query_stats.cpp", line:255, functionName:"toDocument"} The failing query: db.c.aggregate([{ $sortByCount: { $expr: { 'by': 22 } } }]) which desugars to db.c.aggregate([{ $group: { _id: {$expr: { 'by': 22 }, count: { $sum: 1 } } }, { $sort: { count: -1 } } ]) It's hitting this assertion. This is happening because when we parse $expr: { 'by': 22 } we drop the $expr and by: 22 looks like a group expression on the field name "by" with the expression being "22". This is not allowed per the assertion we hit. What we really want is pre-SERVER-84159 behavior that serializes constant expressions with $const in the representative shape so that they are not interpreted as raw constants in cases when that's not allowed during the re-parsing step.

Top User Comments


Steps to Reproduce


Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Open

Learn More

Search:

...