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

db.eval should not implicitly create a database when talking to mongod

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.1.9
    • Component/s: JavaScript
    • Labels:
    • Sharding 2016-08-29

      Running the eval command on a mongos will not implicitly create the database, while running it on a mongod will. These two behaviors should be consistent. If the database doesn't exist, the command should always create it, or never create it, regardless of whether it's talking to a mongos or a mongod.

      Because mongos cannot create a representation of the database without writing durable data, the behavior of mongod should be changed to match that of mongos.

      This behavior was noticed while running a patch build using the --shuffle option to resmoke.py, eval7.js failed during the sharded_collections_jscore_passthrough suite with the following message:

      [js_test:eval7] 2015-10-09T03:32:13.811+0000 2015-10-09T03:32:13.811+0000 E QUERY    [thread1] Error: { "ok" : 0, "errmsg" : "database test not found", "code" : 26 } :
      [js_test:eval7] 2015-10-09T03:32:13.811+0000 _getErrorWithCode@src/mongo/shell/utils.js:23:13
      [js_test:eval7] 2015-10-09T03:32:13.811+0000 DB.prototype.eval@src/mongo/shell/db.js:553:1
      [js_test:eval7] 2015-10-09T03:32:13.811+0000 @jstests/core/eval7.js:2:16
      

      This normally doesn't fail, as it usually isn't the first test to run, and the database will already exist by then.

            Assignee:
            backlog-server-devtools DO NOT USE - Backlog - Dev Tools
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: