[SERVER-43349] Incorrect serialization for $elemMatch $not $ne Created: 16/Sep/19  Updated: 29/Oct/23  Resolved: 27/Nov/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 3.6.15, 4.0.0, 4.0.7, 4.2.0, 4.3.1
Fix Version/s: 4.2.3, 4.3.3, 4.0.15, 3.6.18

Type: Bug Priority: Major - P3
Reporter: James Wahlin Assignee: Charlie Swanson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
is related to SERVER-1454 Use $not as a top-level logical op Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2, v4.0, v3.6
Sprint: Query 2019-10-21, Query 2019-11-04, Query 2019-11-18, Query 2019-12-02
Participants:

 Description   

> db.test.explain().find({ "a" : { "$elemMatch" : { "$not" : { "$ne" : 400 } }}})
{
	"queryPlanner" : {
		"plannerVersion" : 1,
		"namespace" : "test.test",
		"indexFilterSet" : false,
		"parsedQuery" : {
			"a" : {
				"$elemMatch" : {
					"0" : {
						"" : {
							"$not" : {
								"$eq" : 400
							}
						}
					}
				}
			}
		},
		"queryHash" : "53768594",
		"planCacheKey" : "6A5A7DF0",
		"winningPlan" : {
			"stage" : "COLLSCAN",
			"filter" : {
				"a" : {
					"$elemMatch" : {
						"0" : {
							"" : {
								"$not" : {
									"$eq" : 400
								}
							}
						}
					}
				}
			},
			"direction" : "forward"
		},
		"rejectedPlans" : [ ]
	},
	"ok" : 1
}
> 



 Comments   
Comment by Githook User [ 27/Jan/20 ]

Author:

{'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310', 'name': 'Charlie Swanson'}

Message: SERVER-43349 Skip double-$not during $elemMatch serialization
Branch: v3.6
https://github.com/mongodb/mongo/commit/766844f616a6e53af5852f0d7d05141315cb0bf7

Comment by Githook User [ 19/Dec/19 ]

Author:

{'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310'}

Message: SERVER-43349 Accommodate double $nots during serialization

(cherry picked from commit 4d1ce1b892eef6f3926548a7b34d020a02eaee8a)
(cherry picked from commit 25fffe65b90ffb3e32911ba021d6952086f5e5e1)
Branch: v4.0
https://github.com/mongodb/mongo/commit/ac93b1aafe2578fbdc1a099323e28b408f351de9

Comment by Githook User [ 19/Dec/19 ]

Author:

{'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310'}

Message: SERVER-43349 Accommodate double $nots during serialization

(cherry picked from commit 4d1ce1b892eef6f3926548a7b34d020a02eaee8a)
Branch: v4.2
https://github.com/mongodb/mongo/commit/4b2c96acbfa413784f1eb0b1d416927754a430ad

Comment by Githook User [ 27/Nov/19 ]

Author:

{'email': 'charlie.swanson@mongodb.com', 'name': 'Charlie Swanson', 'username': 'cswanson310'}

Message: SERVER-43349 Accommodate double $nots during serialization
Branch: master
https://github.com/mongodb/mongo/commit/4d1ce1b892eef6f3926548a7b34d020a02eaee8a

Comment by Charlie Swanson [ 09/Oct/19 ]

It looks like this also affects the limited backport fix for 3.6 recently completed under SERVER-39019. Once I get some feedback on the fix on master I can look into a similar targeted fix for the older branches.

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