Misleading error when inserting into collection with long name.

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: 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
    • 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 Stearn
            Reporter:
            A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: