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

createIndexes: 'createdCollectionAutomatically' value is incorrect when collection creation fails

    • Fully Compatible
    • ALL
    • Hide
      var myDB = db.getSiblingDB('bugs');
      var collName = new Array(120).join('z');
      var coll = myDB[collName];
      var res = coll.runCommand('createIndexes', {indexes: [{key: {'test': 1}, name: 'test'}]});
      
      // no collection was actually created
      assert.eq(0, myDB.getCollectionNames().length);
      
      // but the result document reports true and this assert fails
      assert.eq(res.createdCollectionAutomatically, false, tojson(res));
      
      Show
      var myDB = db.getSiblingDB('bugs'); var collName = new Array(120).join('z'); var coll = myDB[collName]; var res = coll.runCommand('createIndexes', {indexes: [{key: {'test': 1}, name: 'test'}]}); // no collection was actually created assert.eq(0, myDB.getCollectionNames().length); // but the result document reports true and this assert fails assert.eq(res.createdCollectionAutomatically, false, tojson(res));
    • Query 10 (02/22/16)

      The createIndexes command will report that a collection has been created even if the creation of the new collection fails:

      {
      	"createdCollectionAutomatically" : true,
      	"errmsg" : "exception: fully qualified namespace bugz.zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz is too long (max is 120 bytes)",
      	"code" : 17381,
      	"ok" : 0
      }
      

      Version: 7aad87285f8149e1979699d9767815740e98dff4

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            kamran.khan Kamran K.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: