-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Query Execution
-
Fully Compatible
-
ALL
-
v8.0
-
200
Minimal reproduction script:
db.coll.drop(); assert.commandWorked(db.coll.insertMany([ {_id: 1, "obj": {"obj": {} } }, {_id: 2 }, ])); const result = db.coll.aggregate([{$addFields: {"obj": null}}, {$sort: {"obj.obj": 1, _id: 1}}]).toArray(); jsTestLog(result);
Incorrect result:
[jsTest] ---- [jsTest] [ { "_id" : 2, "obj" : null }, { "_id" : 1, "obj" : null } ] [jsTest] ----
Note that the order of returned documents is wrong. The document is marked as modified after passing the $addFields stage. The top-level "obj" field is in the document cache. Document::getNestedFieldNonCachingHelper function ignores the cache and returns the "obj.obj" field in the backing BSON.
- related to
-
SERVER-91118 Reading cached document field after the field is removed returns incorrect result
-
- Closed
-
-
SERVER-87632 Remove unnecessary variant from SortKeyGenerator hot path
-
- Closed
-