[SERVER-78650] Change stream oplog rewrite of $nor hits empty-array validation if no children are eligible for rewrite Created: 03/Jul/23 Updated: 29/Oct/23 Resolved: 15/Aug/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 6.0.0, 7.0.0-rc0 |
| Fix Version/s: | 7.1.0-rc0, 6.0.10, 7.0.2 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Bernard Gorman | Assignee: | Milena Ivanova |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Query Execution
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Operating System: | ALL | ||||||||||||
| Backport Requested: |
v7.0, v6.0
|
||||||||||||
| Participants: | |||||||||||||
| Linked BF Score: | 57 | ||||||||||||
| Description |
|
When a $nor is rewritten as part of the change stream oplog filter and none of its children are eligible for a rewrite, an empty $nor is left in the MatchExpression tree. We do the same for $and, but in that case our subsequent call to MatchExpression::optimize when the filter is complete removes the empty $ands (and any empty $ors, though our rewrites do not produce these) from the tree. However, we don't perform any such optimization for empty $nor. Therefore, when we subsequently run the rewritten filter through parseTreeTopLevel, we end up throwing when it sees the empty $nor array. The symptoms are worsened by the fact that we also rewrite the user $match into the buildTransactionFilter, but only a very limited set of fields. This means that even if the children of the $nor are generally eligible for rewrites (e.g. operationType), they may be excluded from this second rewrite, and thus will end up producing an empty $nor. The bug doesn't manifest if the $nor only has a single child, because the initial optimization pass will unwrap the $nor into a $not of the child predicate, and so we never attempt to rewrite the $nor. To fix this issue, we could perform a similar optimization-away of empty $nor as is already done for $and and $or. |
| Comments |
| Comment by Githook User [ 25/Aug/23 ] |
|
Author: {'name': 'Peter Volk', 'email': 'peter.volk@mongodb.com', 'username': 'HCSPete'}Message: |
| Comment by Githook User [ 24/Aug/23 ] |
|
Author: {'name': 'Peter Volk', 'email': 'peter.volk@mongodb.com', 'username': 'HCSPete'}Message: if no children are eligible for rewrite |
| Comment by Githook User [ 02/Aug/23 ] |
|
Author: {'name': 'Milena Ivanova', 'email': 'milena.ivanova@mongodb.com', 'username': 'mivanova3'}Message: Exclude test from multiversion lts suites |
| Comment by Githook User [ 01/Aug/23 ] |
|
Author: {'name': 'Milena Ivanova', 'email': 'milena.ivanova@mongodb.com', 'username': 'mivanova3'}Message: Exclude test from multiversion lts suites |
| Comment by Githook User [ 01/Aug/23 ] |
|
Author: {'name': 'Milena Ivanova', 'email': 'milena.ivanova@mongodb.com', 'username': 'mivanova3'}Message: |
| Comment by Githook User [ 31/Jul/23 ] |
|
Author: {'name': 'Milena Ivanova', 'email': 'milena.ivanova@mongodb.com', 'username': 'mivanova3'}Message: |