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

Failed to insert into capped collection when collection contains invalid 2d data

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.8
    • Affects Version/s: 2.6.3
    • Component/s: Geo, Index Maintenance
    • Labels:
      None
    • ALL
    • Hide
      > db.createCollection('a', {capped:true, max:2, size:2})
      > db.a.ensureIndex({loc:'2d'})
      > db.a.insert({ loc: [118333203, 40299390] })
      > db.a.insert({loc: [ 118,42] })
      > db.a.insert({loc: [ 118,42] })
      

      Expected: document #3 to be inserted, #1 to be removed
      Actual: "unindex failed" error.
      Step 3 will fail on the index creation:

      Assertion: 12583:unexpected index insertion failure on capped collection

      However the document is inserted nevertheless. By the time when Mongo tries to remove the index for document #1, we get the "unindex failed" error.

      The desired behavior is Mongo should fail the document insertion if there is an error creating the 2d index. This would be consistent with the new behavior in 2.6 with regard to the long index key handling

      Show
      > db.createCollection( 'a' , {capped: true , max:2, size:2}) > db.a.ensureIndex({loc: '2d' }) > db.a.insert({ loc: [118333203, 40299390] }) > db.a.insert({loc: [ 118,42] }) > db.a.insert({loc: [ 118,42] }) Expected: document #3 to be inserted, #1 to be removed Actual: "unindex failed" error. Step 3 will fail on the index creation: Assertion: 12583:unexpected index insertion failure on capped collection However the document is inserted nevertheless. By the time when Mongo tries to remove the index for document #1, we get the "unindex failed" error. The desired behavior is Mongo should fail the document insertion if there is an error creating the 2d index. This would be consistent with the new behavior in 2.6 with regard to the long index key handling

      With a capped collection that stores taxi driver's location data. They have a 2d index in addition to the _id index on that collection. What they noticed is that once the collection is full, they are not able to inserting new document because of following error:

      unindex failed (key too big?) order.order_endloc.$id key: { : ObjectId('53e3a3cb0cf25dc1e46cc2a2') } _id: ObjectId('53e3a3cb0cf25dc1e46cc2a2')

      They were not able to reproduce this in test environment so had to use the workaround of dropping the collection when it's full and start over.

      I spent some time with them today and was able to figure out the root cause to be some invalid location data. See repro steps for details.

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            jianfa.tang@mongodb.com Jianfa Tang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: