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

Collection with a long key fails validation

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 3.2.0
    • 3.3.2
    • Storage
    • Fully Compatible
    • ALL
    • Hide

      var coll=db.longindex;
      coll.drop();
      var shortVal = new Array(100).join('x');
      var longVal = new Array(1025).join('x'); // Index key must be larger than 1024
       
      db.adminCommand({setParameter: 1, failIndexKeyTooLong: false});
       
      coll.insert({_id: shortVal});
      var res = coll.validate({full: true, scandata: true});
      assert(res.valid, tojson(res));
       
      coll.insert({_id: longVal});
      res = coll.validate({full: true, scandata: true});
      assert(res.valid, tojson(res));
      

      Show
      var coll=db.longindex; coll.drop(); var shortVal = new Array(100).join('x'); var longVal = new Array(1025).join('x'); // Index key must be larger than 1024   db.adminCommand({setParameter: 1, failIndexKeyTooLong: false});   coll.insert({_id: shortVal}); var res = coll.validate({full: true, scandata: true}); assert(res.valid, tojson(res));   coll.insert({_id: longVal}); res = coll.validate({full: true, scandata: true}); assert(res.valid, tojson(res));
    • TIG F (01/29/16), TIG 10 (02/19/16)

    Description

      If a long index key (greater than 1024) is inserted into a collection (when the parameter failIndexKeyTooLong is set to false), then collection validate does not take it into account and fails. This seems to have been introduced from the work in SERVER-19521.

      {
      	"ns" : "test.longindex",
      	"nrecords" : 2,
      	"nIndexes" : 1,
      	"keysPerIndex" : {
      		"test.longindex.$_id_" : 1
      	},
      	"indexDetails" : {
      		"test.longindex.$_id_" : {
      			"valid" : true
      		}
      	},
      	"valid" : false,
      	"errors" : [
      		"number of _id index entries (1) does not match the number of documents (2)"
      	],
      	"advice" : "ns corrupt. See http://dochub.mongodb.org/core/data-recovery",
      	"ok" : 1
      }
      
      

      Attachments

        Issue Links

          Activity

            People

              robert.guo@mongodb.com Robert Guo
              jonathan.abrahams Jonathan Abrahams
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: