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

Misleading error when inserting into collection with long name.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 2.6.0-rc2
    • 2.6.0-rc0
    • Write Ops
    • None
    • Fully Compatible
    • ALL
    • Hide

      var collection_name = '';
      while (collection_name.length < 127) {
          collection_name += 'a';
      }
       
      jsTest.log('collection name length: ' + collection_name.length);
       
      db.collection.drop();
      var result = db.runCommand({
          insert: collection_name,
          documents: [{}]
      });
       
      printjson(result);

      Show
      var collection_name = ''; while (collection_name.length < 127) { collection_name += 'a'; }   jsTest.log('collection name length: ' + collection_name.length);   db.collection.drop(); var result = db.runCommand({ insert: collection_name, documents: [{}] });   printjson(result);

    Description

      Attempting to insert into a collection with a 127-character-long name fails, with the error message: "ns name too long, max size is 127 bytes". I seems it should actually say, "120 bytes."

      If the length of the fully-qualified namespace (db + "." + collection) is at most 127 characters, we get a more accurate error, "fully qualified namespace db.<LONG-COLLECTION-NAME> is too long (max is 120 bytes)".

      Another possible value is 123 bytes, documented here:

      http://docs.mongodb.org/manual/reference/limits/

      Attachments

        Activity

          People

            mathias@mongodb.com Mathias Stearn
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: