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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Duplicate
    • Affects Version/s: 2.0.2, 2.1.0
    • Fix Version/s: None
    • 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
    • Operating System:
      ALL

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: