[SERVER-77301] rewriteGroupByMinMax in timeseries doesn't respect collation Created: 18/May/23  Updated: 29/Oct/23  Resolved: 30/May/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0, 6.0.7, 7.0.0-rc4

Type: Bug Priority: Major - P3
Reporter: Irina Yatsenko (Inactive) Assignee: Irina Yatsenko (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0, v6.0, v5.0
Steps To Reproduce:

db.createCollection("ts", {timeseries:

{timeField: 'time', metaField: 'meta'}

, collation: {locale: "en", numericOrdering: true}})

ts.insertMany([\{time: ISODate(), meta: 1, value: "10"}, \{time: ISODate(), meta: 1, value: "5"}])

db.ts.explain().aggregate([\{$group: {_id: "$meta", m: {$max: "$value"}}}], {collation: {locale: 'en', numericOrdering: false}})

the query returns wrong result of {_id: 1, m: "10" } instead of {_id: 1, m: "5" } which is the max in lexicographic order.

Sprint: QI 2023-05-29, QI 2023-06-12
Participants:

 Description   

The rewrite of group with min/max accumulators takes advantage of the min/max being stored for each bucket so it can completely avoid unpacking if the group id is such that it would include whole buckets into each group (currently we do the rewrite only for group by meta field). However, buckets' min/max are computed using the collection's collation and they shouldn't be used if the query specifies a different collation.



 Comments   
Comment by Githook User [ 13/Jun/23 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-77301 Do not rewrite group in timeseries if collation does not match
Branch: v6.0
https://github.com/mongodb/mongo/commit/04aa837a03f0c87c1d74306744f62f1932b61ffd

Comment by Githook User [ 07/Jun/23 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-77301 Do not rewrite group in timeseries if collation does not match
Branch: v7.0
https://github.com/mongodb/mongo/commit/289c4e18267de261e56c9fd5062716642fa4b283

Comment by Githook User [ 24/May/23 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-77301 Do not rewrite group in timeseries if collation does not match
Branch: master
https://github.com/mongodb/mongo/commit/62f30972b7046afc8ba798066ea3951f0183c9ef

Generated at Thu Feb 08 06:35:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.