[SERVER-83085] Upsert from $nor predicate generates different fields Created: 09/Nov/23  Updated: 06/Feb/24

Status: Needs Scheduling
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Alyssa Clark Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: query-director-triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
is caused by SERVER-81630 Enable Boolean expression simplifier Closed
Assigned Teams:
Query Optimization
Operating System: ALL
Steps To Reproduce:

 MongoDB Enterprise > db.runCommand({
update: "coll",
updates: [{
multi: true,
upsert: true,
q: {
$nor: [{
$or: [
{ "x": 1 }
,
{ "y": 2 }
]
}, {
"x":
{ $ne: 3 }
}]
},
u: [ { "$unset" : "z" } ]
}]
})
{
"n" : 1,
"upserted" : [
{ "index": 0, "_id": ObjectId("654d421587d21e4fb0f54e2e") }
],
"nModified" : 0,
"ok" : 1
}
MongoDB Enterprise > db.coll.find()
{ "_id" : ObjectId("654d421587d21e4fb0f54e2e"), "x" : 3 }

 

Sprint: QO 2024-02-05
Participants:

 Description   

I ran into this while adding upsert support to the update fuzzer during skunkworks (TIG-4521). This appears to be caused by SERVER-81630 - I noticed different behavior after it than before it. Before the change, an upsert with a query like this:

{$nor: [{$or: [{x: 1}, {y: 2}]}, {x: {$ne: 3}}]} 

would insert an empty document (that is, empty aside from _id). After the change, it inserts a document with _id and a field from the $nor predicate (x: 3). This predicate with a $ne and $or nested in a $nor was the simplest one I could find to trigger the differing behavior.


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