-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
The issue only happened with unit months in the generated test but this could be a coincidence. The start and end dates required to reproduce are finicky.
Repro:
// Setup db.a.drop() db.a.aggregate([ { "$densify" : { "field" : "obj.obj.obj.date", "range" : { "step" : 9, "unit" : "month", "bounds" : [ ISODate("2019-01-31T21:53:45.323Z"), ISODate("2020-06-02T10:40:15.842Z") ] } } }, { "$sort" : { "obj.obj.obj.date" : 1, "_id" : 1 } }, { "$limit" : 1000 } ]) // Result: // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-01-31T21:53:45.323Z") } } } } // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-10-31T21:53:45.323Z") } } } } // ----- // Adding a document in the range produces additional documents at the start of the densify range db.a.insert({obj: {obj: {obj: {date: new Date("2019-10-01")}}}}) db.a.aggregate([ { "$densify" : { "field" : "obj.obj.obj.date", "range" : { "step" : 9, "unit" : "month", "bounds" : [ ISODate("2019-01-31T21:53:45.323Z"), ISODate("2020-06-02T10:40:15.842Z") ] } } }, { "$sort" : { "obj.obj.obj.date" : 1, "_id" : 1 } }, { "$limit" : 1000 } ]) // Result: // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-01-30T21:53:45.323Z") } } } } // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-01-31T21:53:45.323Z") } } } } // { "_id" : ObjectId("6772948fbfb88c160d07a21e"), "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-10-01T00:00:00Z") } } } } // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-10-31T21:53:45.323Z") } } } } // ------ // Worse yet the number of erroneous documents is linear in the number of intermediary documents db.a.insert({obj: {obj: {obj: {date: new Date("2019-10-01")}}}}) db.a.aggregate([ { "$densify" : { "field" : "obj.obj.obj.date", "range" : { "step" : 9, "unit" : "month", "bounds" : [ ISODate("2019-01-31T21:53:45.323Z"), ISODate("2020-06-02T10:40:15.842Z") ] } } }, { "$sort" : { "obj.obj.obj.date" : 1, "_id" : 1 } }, { "$limit" : 1000 } ]) // Result: // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-01-30T21:53:45.323Z") } } } } // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-01-30T21:53:45.323Z") } } } } // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-01-31T21:53:45.323Z") } } } } // { "_id" : ObjectId("6772948fbfb88c160d07a21e"), "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-10-01T00:00:00Z") } } } } // { "_id" : ObjectId("677294cbbfb88c160d07a220"), "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-10-01T00:00:00Z") } } } } // { "obj" : { "obj" : { "obj" : { "date" : ISODate("2019-10-31T21:53:45.323Z") } } } }
- causes
-
SERVER-98823 Investigate issues related to month bounds in densify
- Closed