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

Prevent creation of database "Admin" or any combination of upper/lowercase letters other than "admin"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.0.0
    • Component/s: Storage
    • ALL
    • Hide

      In order to reproduce follow these steps on a freshly created replica set:

      replset:PRIMARY> rs.status()
      {
      	"set" : "replset",
      	"date" : ISODate("2016-04-13T01:39:20.523Z"),
      	"myState" : 1,
      	"members" : [
      		{
      			"_id" : 0,
      			"name" : "127.0.0.1:27017",
      			"health" : 1,
      			"state" : 1,
      			"stateStr" : "PRIMARY",
      			"uptime" : 8,
      			"optime" : Timestamp(1460511552, 1),
      			"optimeDate" : ISODate("2016-04-13T01:39:12Z"),
      			"electionTime" : Timestamp(1460511556, 1),
      			"electionDate" : ISODate("2016-04-13T01:39:16Z"),
      			"configVersion" : 1,
      			"self" : true
      		},
      		{
      			"_id" : 1,
      			"name" : "127.0.0.1:27018",
      			"health" : 1,
      			"state" : 5,
      			"stateStr" : "STARTUP2",
      			"uptime" : 8,
      			"optime" : Timestamp(0, 0),
      			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      			"lastHeartbeat" : ISODate("2016-04-13T01:39:18.523Z"),
      			"lastHeartbeatRecv" : ISODate("2016-04-13T01:39:18.523Z"),
      			"pingMs" : 0,
      			"configVersion" : 1
      		},
      		{
      			"_id" : 2,
      			"name" : "127.0.0.1:27019",
      			"health" : 1,
      			"state" : 5,
      			"stateStr" : "STARTUP2",
      			"uptime" : 8,
      			"optime" : Timestamp(0, 0),
      			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      			"lastHeartbeat" : ISODate("2016-04-13T01:39:18.523Z"),
      			"lastHeartbeatRecv" : ISODate("2016-04-13T01:39:18.523Z"),
      			"pingMs" : 0,
      			"configVersion" : 1
      		}
      	],
      	"ok" : 1
      }
      replset:PRIMARY> db.version()
      3.0.11
      replset:PRIMARY> use Admin
      switched to db Admin
      replset:PRIMARY> db.Admin.insert({1:1})
      WriteResult({ "nInserted" : 1 })
      replset:PRIMARY> use gotham
      switched to db gotham
      replset:PRIMARY> db.arkham.insert({1:1})
      WriteResult({ "nInserted" : 1 })
      replset:PRIMARY> db.arkham.renameCollection("test")
      { "ok" : 1 }
      replset:PRIMARY> rs.status()
      2016-04-13T11:40:27.514+1000 I NETWORK  DBClientCursor::init call() failed
      2016-04-13T11:40:27.523+1000 E QUERY    Error: error doing query: failed
          at DBQuery._exec (src/mongo/shell/query.js:83:36)
          at DBQuery.hasNext (src/mongo/shell/query.js:240:10)
          at DBCollection.findOne (src/mongo/shell/collection.js:187:19)
          at DB.runCommand (src/mongo/shell/db.js:58:41)
          at DB.adminCommand (src/mongo/shell/db.js:66:41)
          at Function.rs.status (src/mongo/shell/utils.js:937:37)
          at (shell):1:4 at src/mongo/shell/query.js:83
      2016-04-13T11:40:27.524+1000 I NETWORK  trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
      2016-04-13T11:40:27.525+1000 I NETWORK  reconnect 127.0.0.1:27017 (127.0.0.1) ok
      replset:SECONDARY> rs.status()
      {
      	"set" : "replset",
      	"date" : ISODate("2016-04-13T01:40:31.705Z"),
      	"myState" : 2,
      	"members" : [
      		{
      			"_id" : 0,
      			"name" : "127.0.0.1:27017",
      			"health" : 1,
      			"state" : 2,
      			"stateStr" : "SECONDARY",
      			"uptime" : 79,
      			"optime" : Timestamp(1460511624, 1),
      			"optimeDate" : ISODate("2016-04-13T01:40:24Z"),
      			"configVersion" : 1,
      			"self" : true
      		},
      		{
      			"_id" : 1,
      			"name" : "127.0.0.1:27018",
      			"health" : 0,
      			"state" : 8,
      			"stateStr" : "(not reachable/healthy)",
      			"uptime" : 0,
      			"optime" : Timestamp(0, 0),
      			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      			"lastHeartbeat" : ISODate("2016-04-13T01:40:30.642Z"),
      			"lastHeartbeatRecv" : ISODate("2016-04-13T01:40:24.625Z"),
      			"pingMs" : 0,
      			"lastHeartbeatMessage" : "Failed attempt to connect to 127.0.0.1:27018; couldn't connect to server 127.0.0.1:27018 (127.0.0.1), connection attempt failed",
      			"configVersion" : -1
      		},
      		{
      			"_id" : 2,
      			"name" : "127.0.0.1:27019",
      			"health" : 0,
      			"state" : 8,
      			"stateStr" : "(not reachable/healthy)",
      			"uptime" : 0,
      			"optime" : Timestamp(0, 0),
      			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      			"lastHeartbeat" : ISODate("2016-04-13T01:40:30.641Z"),
      			"lastHeartbeatRecv" : ISODate("2016-04-13T01:40:24.625Z"),
      			"pingMs" : 0,
      			"lastHeartbeatMessage" : "Failed attempt to connect to 127.0.0.1:27019; couldn't connect to server 127.0.0.1:27019 (127.0.0.1), connection attempt failed",
      			"configVersion" : -1
      		}
      	],
      	"ok" : 1
      }
      replset:SECONDARY> 
      

      Regards,
      Markus

      Show
      In order to reproduce follow these steps on a freshly created replica set: replset:PRIMARY> rs.status() { "set" : "replset" , "date" : ISODate( "2016-04-13T01:39:20.523Z" ), "myState" : 1, "members" : [ { "_id" : 0, "name" : "127.0.0.1:27017" , "health" : 1, "state" : 1, "stateStr" : "PRIMARY" , "uptime" : 8, "optime" : Timestamp(1460511552, 1), "optimeDate" : ISODate( "2016-04-13T01:39:12Z" ), "electionTime" : Timestamp(1460511556, 1), "electionDate" : ISODate( "2016-04-13T01:39:16Z" ), "configVersion" : 1, "self" : true }, { "_id" : 1, "name" : "127.0.0.1:27018" , "health" : 1, "state" : 5, "stateStr" : "STARTUP2" , "uptime" : 8, "optime" : Timestamp(0, 0), "optimeDate" : ISODate( "1970-01-01T00:00:00Z" ), "lastHeartbeat" : ISODate( "2016-04-13T01:39:18.523Z" ), "lastHeartbeatRecv" : ISODate( "2016-04-13T01:39:18.523Z" ), "pingMs" : 0, "configVersion" : 1 }, { "_id" : 2, "name" : "127.0.0.1:27019" , "health" : 1, "state" : 5, "stateStr" : "STARTUP2" , "uptime" : 8, "optime" : Timestamp(0, 0), "optimeDate" : ISODate( "1970-01-01T00:00:00Z" ), "lastHeartbeat" : ISODate( "2016-04-13T01:39:18.523Z" ), "lastHeartbeatRecv" : ISODate( "2016-04-13T01:39:18.523Z" ), "pingMs" : 0, "configVersion" : 1 } ], "ok" : 1 } replset:PRIMARY> db.version() 3.0.11 replset:PRIMARY> use Admin switched to db Admin replset:PRIMARY> db.Admin.insert({1:1}) WriteResult({ "nInserted" : 1 }) replset:PRIMARY> use gotham switched to db gotham replset:PRIMARY> db.arkham.insert({1:1}) WriteResult({ "nInserted" : 1 }) replset:PRIMARY> db.arkham.renameCollection( "test" ) { "ok" : 1 } replset:PRIMARY> rs.status() 2016-04-13T11:40:27.514+1000 I NETWORK DBClientCursor::init call() failed 2016-04-13T11:40:27.523+1000 E QUERY Error: error doing query: failed at DBQuery._exec (src/mongo/shell/query.js:83:36) at DBQuery.hasNext (src/mongo/shell/query.js:240:10) at DBCollection.findOne (src/mongo/shell/collection.js:187:19) at DB.runCommand (src/mongo/shell/db.js:58:41) at DB.adminCommand (src/mongo/shell/db.js:66:41) at Function.rs.status (src/mongo/shell/utils.js:937:37) at (shell):1:4 at src/mongo/shell/query.js:83 2016-04-13T11:40:27.524+1000 I NETWORK trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed 2016-04-13T11:40:27.525+1000 I NETWORK reconnect 127.0.0.1:27017 (127.0.0.1) ok replset:SECONDARY> rs.status() { "set" : "replset" , "date" : ISODate( "2016-04-13T01:40:31.705Z" ), "myState" : 2, "members" : [ { "_id" : 0, "name" : "127.0.0.1:27017" , "health" : 1, "state" : 2, "stateStr" : "SECONDARY" , "uptime" : 79, "optime" : Timestamp(1460511624, 1), "optimeDate" : ISODate( "2016-04-13T01:40:24Z" ), "configVersion" : 1, "self" : true }, { "_id" : 1, "name" : "127.0.0.1:27018" , "health" : 0, "state" : 8, "stateStr" : "(not reachable/healthy)" , "uptime" : 0, "optime" : Timestamp(0, 0), "optimeDate" : ISODate( "1970-01-01T00:00:00Z" ), "lastHeartbeat" : ISODate( "2016-04-13T01:40:30.642Z" ), "lastHeartbeatRecv" : ISODate( "2016-04-13T01:40:24.625Z" ), "pingMs" : 0, "lastHeartbeatMessage" : "Failed attempt to connect to 127.0.0.1:27018; couldn't connect to server 127.0.0.1:27018 (127.0.0.1), connection attempt failed" , "configVersion" : -1 }, { "_id" : 2, "name" : "127.0.0.1:27019" , "health" : 0, "state" : 8, "stateStr" : "(not reachable/healthy)" , "uptime" : 0, "optime" : Timestamp(0, 0), "optimeDate" : ISODate( "1970-01-01T00:00:00Z" ), "lastHeartbeat" : ISODate( "2016-04-13T01:40:30.641Z" ), "lastHeartbeatRecv" : ISODate( "2016-04-13T01:40:24.625Z" ), "pingMs" : 0, "lastHeartbeatMessage" : "Failed attempt to connect to 127.0.0.1:27019; couldn't connect to server 127.0.0.1:27019 (127.0.0.1), connection attempt failed" , "configVersion" : -1 } ], "ok" : 1 } replset:SECONDARY> Regards, Markus
    • Storage NYC 2018-07-02

      When creating a database called "Admin" (or any upper/lowercase letter combination of "Admin" other than "admin") and then executing db.collection.renameCollection() on a different collection crashes all secondaries in a replica set.

            Assignee:
            ben.judd Ben Judd
            Reporter:
            markus.thielsch@mongodb.com Markus Thielsch
            Votes:
            1 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: