[SERVER-12828] Reindexing drops indexes if key contains values too large to index Created: 21/Feb/14  Updated: 10/Dec/14  Resolved: 23/Feb/14

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.6.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Jeff lee Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-8391 Pre-flight upgrade tool to check for ... Closed
is related to SERVER-5290 fail to insert docs with fields too l... Closed
Operating System: ALL
Steps To Reproduce:

[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" }

Participants:

 Description   

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.



 Comments   
Comment by Daniel Pasette (Inactive) [ 23/Feb/14 ]

If a user has documents with index keys longer than the maximum in 2.6, the workaround is to use the server parameter detailed in SERVER-12834 to revert to pre-2.6 behavior.

Comment by Jeff lee [ 21/Feb/14 ]

Thanks Dan. Asya pointed this exists as a warning in the release notes.

Comment by Asya Kamsky [ 21/Feb/14 ]

Release notes do describe this as expected behavior post-upgrade:

http://docs.mongodb.org/master/release-notes/2.6/#stricter-enforcement-of-index-key-length-limit

Comment by Daniel Pasette (Inactive) [ 21/Feb/14 ]

Jeff,
There is an "upgradeCheck" tool designed to help users avoid issues with upgrading. See SERVER-8391 for more details.

The behavior with issues related to the stricter enforcement of index key length is described here: SERVER-5290.

Generated at Thu Feb 08 03:29:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.