[SERVER-2086] Prevent creating collections on the 'admin' database and sharding them Created: 09/Nov/10  Updated: 12/Jul/16  Resolved: 31/Mar/11

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 1.9.0

Type: Bug Priority: Trivial - P5
Reporter: Alberto Lerner Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

1.I'm running shard server

./mongod --shardsvr --dbpath /data/r1/ --port 10000

2.Configuration server

./mongod --configsvr --dbpath /data/db/config/ --port 20000

3.mongos server
./mongos --configdb localhost:20000 --port 30000

4.client

./mongo localhost:30000/admin

Here I'm creating collection table and insert with 1 key called
"name"
db.table1.find();

{ "_id" : ObjectId("4cd7ed644ab7a52e8ac54309"), "name" : "1" } { "_id" : ObjectId("4cd7ed7f4ab7a52e8ac5430a"), "name" : "3" } { "_id" : ObjectId("4cd7ed864ab7a52e8ac5430b"), "name" : "4" } { "_id" : ObjectId("4cd7ed8c4ab7a52e8ac5430c"), "name" : "5" } { "_id" : ObjectId("4cd7ed914ab7a52e8ac5430d"), "name" : "6" } { "_id" : ObjectId("4cd7ed964ab7a52e8ac5430e"), "name" : "7" } { "_id" : ObjectId("4cd7ed9f4ab7a52e8ac5430f"), "name" : "8" } { "_id" : ObjectId("4cd7eda54ab7a52e8ac54310"), "name" : "9" } { "_id" : ObjectId("4cd7edaa4ab7a52e8ac54311"), "name" : "20" }

and then i performing these steps to add and enable sharding

> db.runCommand(

{ addshard : "localhost:10000" }

);

{ "shardAdded" : "shard0000", "ok" : 1 }

> db.runCommand(

{ enablesharding : "admin" }

)

{ "ok" : 1 }

>db.table1.ensureIndex(

{ name: 1 }

);

> db.runCommand( { shardcollection : "admin.table1",key :

{name : 1}

,unique:true });

{ "collectionsharded" : "admin.table1", "ok" : 1 }

>db.printShardingStatus()

— Sharding Status —
sharding version:

{ "_id" : 1, "version" : 3 }

shards:

{ "_id" : "shard0000", "host" : "localhost:10000" }

databases:

{ "_id" : "admin", "partitioned" : true, "primary" : "config" }

admin.table1 chunks:
{ "name" :

{ $minKey : 1 }

} -->> { "name" :

{ $maxKey : 1 }

} on :
config

{ "t" : 1000, "i" : 0 }

when i want to see the collection items it's showing like this

> db.table1.find();
error:

{ "$err" : "can't find shard for: localhost:20000", "code" : 13129 }

 Comments   
Comment by auto [ 31/Mar/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: don't allow sharding admin db SERVER-2086
Branch: master
https://github.com/mongodb/mongo/commit/67ba94424e8282787c5833edcf8e5ab29934c2ac

Generated at Thu Feb 08 02:58:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.