[SERVER-82446] $densify use case can result in documents outside of range Created: 25/Oct/23  Updated: 30/Oct/23  Resolved: 27/Oct/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 7.0.2, 6.0.11, 7.1.0
Fix Version/s: 7.2.0-rc0, 6.0.12, 7.0.4

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

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0, v6.0
Steps To Reproduce:

 

db.dropDatabase();
 
const pipeline = [
  {"$densify": {
      "field": "num",
      "partitionByFields": [ "key" ],
      "range": {
        "step": 1,
        "bounds": [
          4,
          8
        ]
      }
  }},
  {$sort: { num: 1}},
  {$project: { _id: 0, num: 1 }}
];
// Expected result set is [4,5,6,7].
assert.eq(4, db.collection.aggregate(pipeline).itcount());
 
db.collection.insertMany([
  {"key": 1,"num": 2},
  {"key": 1,"num": 4},  {"key": 1,"num": 6}
]);
// Expected result set is [2,4,5,6,7]. Fails assert with a result set of [2,3,4,4,5,6,7].
assert.eq(5, db.collection.aggregate(pipeline).itcount());

Sprint: QI 2023-10-30
Participants:

 Description   

Affects $densify stages that use both 'partitionByFields' and 'range', and for which values exist both below the range and matching the lower bound



 Comments   
Comment by Githook User [ 30/Oct/23 ]

Author:

{'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}

Message: SERVER-82446 Fix $densify scenario where documents are generated outside of range

(cherry picked from commit 0c2b021ed730f0c6b925c6a7e725562f893520e4)
Branch: v6.0
https://github.com/mongodb/mongo/commit/ddbe1375ea56c96e27beccb60e07bccfd0f6a146

Comment by Githook User [ 27/Oct/23 ]

Author:

{'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}

Message: SERVER-82446 Fix $densify scenario where documents are generated outside of range

(cherry picked from commit 0c2b021ed730f0c6b925c6a7e725562f893520e4)
Branch: v7.0
https://github.com/mongodb/mongo/commit/33968bda5de2b10009f51339ba3e20eba01e7675

Comment by Githook User [ 27/Oct/23 ]

Author:

{'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}

Message: SERVER-82446 Fix $densify scenario where documents are generated outside of range
Branch: master
https://github.com/mongodb/mongo/commit/0c2b021ed730f0c6b925c6a7e725562f893520e4

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