[SERVER-72416] The find and findAndModify projection code does not honor the collection level collation Created: 28/Dec/22 Updated: 29/Oct/23 Resolved: 06/Jan/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 4.4.18, 5.0.14, 6.0.3 |
| Fix Version/s: | 6.0.4, 6.2.0-rc5, 6.3.0-rc0 |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Arun Banala | Assignee: | Arun Banala |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||
| Backport Requested: |
v6.2, v6.0, v5.0, v4.4
|
||||||||||||||||||||
| Sprint: | QE 2023-01-09 | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||
| Linked BF Score: | 3 | ||||||||||||||||||||
| Description |
|
Issue Status as of May 16, 2023 ISSUE DESCRIPTION AND AFFECTED VERSIONS When a collation on the collection level is specified, the find, findAndModify, and findOneAndDelete commands that use projection are affected by a bug that may cause MongoDB to crash after performing deletes without sending an acknowledgement to the user. This bug may also cause $sortArray in the projection to provide incorrect query results when sorting strings. Find commands that use projection use the ExpressionContext object, which does not inherit collection level collation. All expressions used inside of the projection command will use the default collation, unless explicitly specified. The find, findAndModify, findOneAndDelete commands are impacted when:
Meeting all of the requirements above, if the query uses $elemMatch with positional projection ($ operator) it will cause a server crash. The findAndModify with {remove: true} and findOneAndDelete command may crash after issuing deletes without sending an acknowledgement to the user. When the $sortArray is used in the projection, the find query will not use collection level collation, but will instead sort strings using a simple collation. DIAGNOSIS AND AFFECTED VERSIONS Nodes that hit this bug will crash with an invariant failure. REMEDIATION AND WORKAROUNDS This issue is fixed in 6.0.4. Original Description:The find projection parsing code uses a very naive ExpressionContext object which does not inherit collection level collation. This means the expression evaluation code inside the projection spec does not use the collection level collation, leading to incorrect results. |
| Comments |
| Comment by Githook User [ 23/Jan/23 ] |
|
Author: {'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}Message: Revert " This reverts commit aed1cb6469f207e7e6ab053fdfb2c472b7b345ec. |
| Comment by Githook User [ 06/Jan/23 ] |
|
Author: {'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}Message: (cherry picked from commit 8fb9a8b130995a379fa1943233e9b91816cebd34) |
| Comment by James Hippler (Inactive) [ 06/Jan/23 ] |
|
We're scheduled to release 6.0.4-rc0 on Tuesday, January 10th. I'm going through any outstanding items in the 6.0 Release Board for status updates.
|
| Comment by Githook User [ 05/Jan/23 ] |
|
Author: {'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}Message: (cherry picked from commit 2f1b039897aa55eb3007abbe1020e6e4967b4140) |
| Comment by Githook User [ 05/Jan/23 ] |
|
Author: {'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}Message: (cherry picked from commit 8fb9a8b130995a379fa1943233e9b91816cebd34) |
| Comment by Githook User [ 05/Jan/23 ] |
|
Author: {'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}Message: |