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

renameCollection must be run on the admin database on mongod but can be run on any database through mongos

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change
    • ALL
    • Hide
      MongoDB shell version: 2.5.3-pre-
      connecting to: 127.0.0.1:30999/test
      mongos> use admin
      switched to db admin
      mongos> db.addUser({user: "admin", pwd: "password", roles: ["userAdminAnyDatabase", "readWriteAnyDatabase", "clusterAdmin"]})
      {
      	"user" : "admin",
      	"roles" : [
      		"userAdminAnyDatabase",
      		"readWriteAnyDatabase",
      		"clusterAdmin"
      	]
      }
      mongos> db.auth("admin", "password")
      1
      mongos> use test
      switched to db test
      mongos> db.x.save({})
      mongos> db.addUser({user: "x", pwd: "x", roles: ["readWriteAnyDatabase"]})
      { "user" : "x", "roles" : [ "readWriteAnyDatabase" ] }
      mongos> db.auth("x", "x")
      1
      mongos> db.runCommand({renameCollection: "test.x", to: "test.y"})
      { "ok" : 1 }
      

      The final command above should give the error "renameCollection may only be run against the admin database."

      Show
      MongoDB shell version: 2.5.3-pre- connecting to: 127.0.0.1:30999/test mongos> use admin switched to db admin mongos> db.addUser({user: "admin" , pwd: "password" , roles: [ "userAdminAnyDatabase" , "readWriteAnyDatabase" , "clusterAdmin" ]}) { "user" : "admin" , "roles" : [ "userAdminAnyDatabase" , "readWriteAnyDatabase" , "clusterAdmin" ] } mongos> db.auth( "admin" , "password" ) 1 mongos> use test switched to db test mongos> db.x.save({}) mongos> db.addUser({user: "x" , pwd: "x" , roles: [ "readWriteAnyDatabase" ]}) { "user" : "x" , "roles" : [ "readWriteAnyDatabase" ] } mongos> db.auth( "x" , "x" ) 1 mongos> db.runCommand({renameCollection: "test.x" , to: "test.y" }) { "ok" : 1 } The final command above should give the error "renameCollection may only be run against the admin database."

      The renameCollection command must be run on the admin database through mongod. When connected to mongos, however, the renameCollection command may be run on any database. We should make this consistent, probably by making it so that even on mongos renameCollection must be run on the admin database.

      Tested against githash c70a72b151fcfab26d0db5e8ceeb7c04a96ce449

            Assignee:
            spencer@mongodb.com Spencer Brody (Inactive)
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: