-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.6.8
-
Component/s: Aggregation Framework, Querying
-
None
-
Fully Compatible
-
ALL
-
In sharded cluster aggregation by _id alone results in duplicate records in case of orphan records exists on the other shards.
If the record with _id = 1 exists on the shard A (active) and shard B (orphan), the following aggregate will return 2 records.
db.test.aggregate([{$match: {_id: 1} }])
It just happens that this is the suggested way of getting an accurate (along with $group stage) count in sharded cluster in the documentation.
The incorrect behaviour is not noticed in 2.4.x and 3.0.0-rc11.