-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
Fully Compatible
-
v8.0, v7.3
-
200
update operation with upsert: true upserts a new document if the filter does not match any documents. The new document is the combination of fields from the filter and the update expressions. The query engine ignores any fields in the filter which are behind negations ($nor, $not). However, the Boolean simplifier, introduced in 7.3, can simplify such expressions and remove some negations.
Let's take a look at the filter expression with root $nor:
{$nor: [{$or: [{"x": 1}, {"y": 2}]}, {"x": {$ne: 3}}]}
since everything is behind $nor the query engine cannot extract any field values for the document to upsert. However, the Boolean simplifier will simplify such expression to
{x: {$eq: 3, $ne: 1}, y: {$ne: 2}}
Now the query engine can extract
{x: 3}
for the document to upsert. This brings the issue of inconsistent behaviour depending on whether the simplifier enabled or not, which is incorrect since the simplifier shouldn't change the query's semantics. We decided to disable the simplifier for upsert operations until we come up the better solution.
- related to
-
SERVER-83085 Enforce consistent upsert semantics
- Needs Scheduling