$sample gives persistent error on uniform shape collection

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.1.8
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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...

              Assignee:
              Unassigned
              Reporter:
              Asya Kamsky
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: