[SERVER-59840] Make change stream mixed-collator check more robust Created: 08/Sep/21  Updated: 29/Oct/23  Resolved: 15/Sep/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Bernard Gorman Assignee: Justin Seyster
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-58514 Add "fullDocument" to fields eligible... Closed
is related to SERVER-59426 Do not mix collations during change s... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2021-09-20
Participants:

 Description   

In SERVER-59426, we forbid change streams from engaging in oplog rewrites in cases where the user specified a non-simple collation. However, in SERVER-58514 we discovered that this could still happen and had to add in specific checks to avoid it.

The issue here is that our current check is based on whether the collator set on the ExpressionContext is nullptr or not (see here and here). This works OK for the first time we attempt to do optimization, which runs with the user-specified collation. However, we then temporarily change the collation on the ExpCtx to nullptr right before attempting to absorb the initial $match into the query system. During that process, we call optimize() again with the collation now set to nullptr, which bypasses our checks and incorrectly rewrites the user's filters into the oplog.

We must ensure that, once we see a non-simple collator on the ExpCtx during optimization, any future attempts at optimization will be abandoned, regardless of what the collation is at that point. We should also remove the additional code added to handled this in SERVER-58514.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 15/Sep/21 ]

Author:

{'name': 'Justin Seyster', 'email': 'justin.seyster@mongodb.com', 'username': 'jseyster'}

Message: SERVER-59840 Do not perform pipeline optimization with temporary collator
Branch: master
https://github.com/mongodb/mongo/commit/0bc8d6bd356392745764362465cfcbe836b9854a

Generated at Thu Feb 08 05:48:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.