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

Misleading error when inserting into collection with long name.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.6.0-rc2
    • Affects Version/s: 2.6.0-rc0
    • Component/s: 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);
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      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/

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

              Created:
              Updated:
              Resolved: