[SERVER-20503] $sample gives persistent error on uniform shape collection Created: 18/Sep/15  Updated: 18/Sep/15  Resolved: 18/Sep/15

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.1.8
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-20385 $sample stage could not find a non-du... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

I have a collection of two thousand documents where each document is either just _id or _id and integer field "a" (different values).

> db.noindex.aggregate({$sample:{size:2}})
{ "_id" : ObjectId("558479e1acb64a95da32c877"), "a" : 182 }
{ "_id" : ObjectId("558479b5acb64a95da32c3d9") }
> db.noindex.aggregate({$sample:{size:2}})
{ "_id" : ObjectId("558479b5acb64a95da32c3d9") }
{ "_id" : ObjectId("558479e1acb64a95da32c877"), "a" : 182 }
> db.noindex.aggregate({$sample:{size:2}})
{ "_id" : ObjectId("558479b5acb64a95da32c3d9") }
{ "_id" : ObjectId("558479e1acb64a95da32c877"), "a" : 182 }
db.noindex.aggregate({$sample:{size:3}})
assert: command failed: {
	"ok" : 0,
	"errmsg" : "$sample stage could not find a non-duplicate document after 100 while using a random cursor. This is likely a sporadic failure, please try again.",
	"code" : 28799
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:259:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1211:5
@(shell):1:1
 
2015-09-18T15:48:35.893-0400 E QUERY    [thread1] Error: command failed: {
	"ok" : 0,
	"errmsg" : "$sample stage could not find a non-duplicate document after 100 while using a random cursor. This is likely a sporadic failure, please try again.",
	"code" : 28799
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:259:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1211:5
@(shell):1:1

This suggests it's somehow determining duplicate incorrectly or else some other check is wrong...

Note also that sample being run multiple times always returns the same two records, which may be related...



 Comments   
Comment by Asya Kamsky [ 18/Sep/15 ]

Looks like a dup!

Generated at Thu Feb 08 03:54:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.