Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4562

createIndex on array field with unique and dropDups:true gives "Invalid BSONObj size" error instead of duplicate key error if array has 2 or more duplicates

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.0.2, 2.1.0
    • Component/s: Index Maintenance
    • Labels:
      None
    • Environment:
      OS X 64bit 2.0.1, 2.1.x nightly (2011-11-06 build); Linux 64bit 2.0.2
    • ALL

      test> db.things.drop()
      true
      test> db.things.save({"array": [ 1, 2, 3 ]})
      test> db.things.save({"array": [ 2, 3, 4 ]})
      test> db.things.createIndex({array: 1}, {unique: true, dropDups: true})
      Invalid BSONObj size: -286331154 (0xEEEEEEEE) first element: _id: ObjectId('4ef8fc7f7797e97e21a8c7da')
      

      but:

      test> db.things.drop()
      true
      test> db.things.save({"array": [ 1, 2, 3 ]})
      test> db.things.save({"array": [ 2, 3, 4 ]})
      test> db.things.createIndex({array: 1}, {unique: true, dropDups: 1})
      E11000 duplicate key error index: test.things.$array_1  dup key: { : 3.0 }
      

      This only seems to happen if there are 2 or more duplicates in the array; with 1 duplicate, it works correctly with either true or 1 as argument to dropDups

            Assignee:
            aaron Aaron Staple
            Reporter:
            dcrosta Daniel Crosta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: