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

Reindexing drops indexes if key contains values too large to index

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0-rc0
    • Component/s: Index Maintenance
    • None
    • ALL
    • Hide
      [start with 2.4.6]
      db.foodle.ensureIndex({name:1})
      db.foodle.save({ _id:1, name:Array(50000).join('a') })
      
      [upgrade set to 2.6]
      s01:PRIMARY> db.version()
      2.6.0-rc0
      
      s01:PRIMARY> db.system.indexes.find()
      { "v" : 1, "key" : { "_id" : 1 }, "ns" : "test.foodle", "name" : "_id_" }
      { "v" : 1, "key" : { "name" : 1 }, "ns" : "test.foodle", "name" : "name_1" }
      
      s01:PRIMARY> db.foodle.reIndex()
      {
              "nIndexesWas" : 2,
              "ok" : 0,
              "errmsg" : "Btree::insert: key too large to index, failing test.foodle.$name_1 50012 { : \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...\" }",
              "code" : 1
      }
      s01:PRIMARY> db.system.indexes.find()
      { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "test.foodle" }
      
      Show
      [start with 2.4.6] db.foodle.ensureIndex({name:1}) db.foodle.save({ _id:1, name:Array(50000).join( 'a' ) }) [upgrade set to 2.6] s01:PRIMARY> db.version() 2.6.0-rc0 s01:PRIMARY> db.system.indexes.find() { "v" : 1, "key" : { "_id" : 1 }, "ns" : "test.foodle" , "name" : "_id_" } { "v" : 1, "key" : { "name" : 1 }, "ns" : "test.foodle" , "name" : "name_1" } s01:PRIMARY> db.foodle.reIndex() { "nIndexesWas" : 2, "ok" : 0, "errmsg" : "Btree::insert: key too large to index, failing test.foodle.$name_1 50012 { : \" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...\ " }" , "code" : 1 } s01:PRIMARY> db.system.indexes.find() { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "test.foodle" }

      Prior to 2.6, if you have an index on a key and try to insert a value that is too large to index, the insert succeeds, but the index is not updated.

      This was changed in 2.6, but if you do an upgrade and try to reindex a collection that has existing values that are too large, the index is dropped and the rebuild fails.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jlee Jeff lee
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: