summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/database.cpp2
-rw-r--r--db/database.h1
-rw-r--r--jstests/dbcase.js6
-rw-r--r--s/commands_public.cpp4
-rw-r--r--s/config.cpp20
-rw-r--r--s/request.cpp15
-rw-r--r--s/request.h10
-rw-r--r--s/server.cpp1
-rw-r--r--s/shard.cpp2
-rw-r--r--s/strategy.cpp1
-rw-r--r--s/util.h2
-rw-r--r--util/assert_util.h5
12 files changed, 53 insertions, 16 deletions
diff --git a/db/database.cpp b/db/database.cpp
index c605e8f445b..f30c761abc1 100644
--- a/db/database.cpp
+++ b/db/database.cpp
@@ -55,7 +55,7 @@ namespace mongo {
stringstream ss;
ss << "db already exists with different case other: [" << others[i] << "] me [" << nm << "]";
- uasserted( 13297 , ss.str() );
+ uasserted( DatabaseDifferCaseCode , ss.str() );
}
}
diff --git a/db/database.h b/db/database.h
index 6378b2ebfa1..2246adb3a2a 100644
--- a/db/database.h
+++ b/db/database.h
@@ -22,7 +22,6 @@
namespace mongo {
-
/**
* Database represents a database database
* Each database database has its own set of files -- dbname.ns, dbname.0, dbname.1, ...
diff --git a/jstests/dbcase.js b/jstests/dbcase.js
index ff7da6ad515..84357281719 100644
--- a/jstests/dbcase.js
+++ b/jstests/dbcase.js
@@ -6,10 +6,12 @@ a.dropDatabase();
b.dropDatabase();
a.foo.save( { x : 1 } )
-assert.eq( 0 , db.getLastErrorObj().code || 0 , "A" )
+z = db.getLastErrorObj();
+assert.eq( 0 , z.code || 0 , "A : " + tojson(z) )
b.foo.save( { x : 1 } )
-assert.eq( 13297 , db.getLastErrorObj().code || 0 , "A" )
+z = db.getLastErrorObj();
+assert.eq( 13297 , z.code || 0 , "B : " + tojson(z) )
a.dropDatabase();
b.dropDatabase();
diff --git a/s/commands_public.cpp b/s/commands_public.cpp
index 821f90b8108..ad442408cf2 100644
--- a/s/commands_public.cpp
+++ b/s/commands_public.cpp
@@ -128,8 +128,8 @@ namespace mongo {
log() << "DROP DATABASE: " << dbName << endl;
if ( ! conf ){
- log(1) << " passing though drop database for: " << dbName << endl;
- return passthrough( conf , cmdObj , result );
+ result.append( "info" , "database didn't exist" );
+ return true;
}
if ( ! conf->dropDatabase( errmsg ) )
diff --git a/s/config.cpp b/s/config.cpp
index 062f875a0a3..f2128354db5 100644
--- a/s/config.cpp
+++ b/s/config.cpp
@@ -397,6 +397,24 @@ namespace mongo {
// note here that cc->primary == 0.
log() << "couldn't find database [" << database << "] in config db" << endl;
+ { // lets check case
+ ScopedDbConnection conn( configServer.modelServer() );
+ BSONObjBuilder b;
+ b.appendRegex( "_id" , (string)"^" + database + "$" , "i" );
+ BSONObj d = conn->findOne( ShardNS::database , b.obj() );
+ conn.done();
+
+ if ( ! d.isEmpty() ){
+ cc.reset();
+ stringstream ss;
+ ss << "can't have 2 databases that just differ on case "
+ << " have: " << d["_id"].String()
+ << " want to add: " << database;
+
+ uasserted( DatabaseDifferCaseCode ,ss.str() );
+ }
+ }
+
if ( database == "admin" )
cc->_primary = configServer.getPrimary();
else
@@ -409,7 +427,7 @@ namespace mongo {
else {
cc.reset();
log() << "\t can't find a shard to put new db on" << endl;
- uassert( 10185 , "can't find a shard to put new db on" , 0 );
+ uasserted( 10185 , "can't find a shard to put new db on" );
}
}
else {
diff --git a/s/request.cpp b/s/request.cpp
index 4babdffb72a..f8877573854 100644
--- a/s/request.cpp
+++ b/s/request.cpp
@@ -37,7 +37,7 @@
namespace mongo {
Request::Request( Message& m, AbstractMessagingPort* p ) :
- _m(m) , _d( m ) , _p(p){
+ _m(m) , _d( m ) , _p(p) , _didInit(false){
assert( _d.getns() );
_id = _m.header()->id;
@@ -46,9 +46,15 @@ namespace mongo {
_clientInfo = ClientInfo::get( _clientId );
_clientInfo->newRequest( p );
+ }
+
+ void Request::init(){
+ if ( _didInit )
+ return;
+ _didInit = true;
reset();
}
-
+
void Request::reset( bool reload ){
if ( _m.operation() == dbKillCursors ){
return;
@@ -71,6 +77,8 @@ namespace mongo {
}
Shard Request::primaryShard() const {
+ assert( _didInit );
+
if ( _chunkManager ){
if ( _chunkManager->numChunks() > 1 )
throw UserException( 8060 , "can't call primaryShard on a sharded collection" );
@@ -82,7 +90,7 @@ namespace mongo {
}
void Request::process( int attempt ){
-
+ init();
int op = _m.operation();
assert( op > dbMsg );
@@ -143,6 +151,7 @@ namespace mongo {
}
void Request::reply( Message & response , const string& fromServer ){
+ assert( _didInit );
long long cursor =response.header()->getCursor();
if ( cursor ){
cursorCache.storeRef( fromServer , cursor );
diff --git a/s/request.h b/s/request.h
index 5e97619551f..f063d0cd1df 100644
--- a/s/request.h
+++ b/s/request.h
@@ -35,7 +35,7 @@ namespace mongo {
Request( Message& m, AbstractMessagingPort* p );
// ---- message info -----
-
+
const char * getns() const {
return _d.getns();
@@ -53,13 +53,16 @@ namespace mongo {
}
DBConfigPtr getConfig() const {
+ assert( _didInit );
return _config;
}
bool isShardingEnabled() const {
+ assert( _didInit );
return _config->isShardingEnabled();
}
ChunkManagerPtr getChunkManager() const {
+ assert( _didInit );
return _chunkManager;
}
@@ -87,10 +90,11 @@ namespace mongo {
void gotInsert();
+ void init();
+
void reset( bool reload=false );
private:
-
Message& _m;
DbMessage _d;
AbstractMessagingPort* _p;
@@ -103,6 +107,8 @@ namespace mongo {
ClientInfo * _clientInfo;
OpCounters* _counter;
+
+ bool _didInit;
};
typedef map<int,ClientInfo*> ClientCache;
diff --git a/s/server.cpp b/s/server.cpp
index 45a6f1b04f6..00f55bc07ed 100644
--- a/s/server.cpp
+++ b/s/server.cpp
@@ -82,6 +82,7 @@ namespace mongo {
log(5) << "client id: " << hex << r.getClientId() << "\t" << r.getns() << "\t" << dec << r.op() << endl;
}
try {
+ r.init();
setClientId( r.getClientId() );
r.process();
}
diff --git a/s/shard.cpp b/s/shard.cpp
index 3b280954f22..7879cc031dc 100644
--- a/s/shard.cpp
+++ b/s/shard.cpp
@@ -223,6 +223,4 @@ namespace mongo {
_writeLock = 0; // TODO
}
-
- const int StaleConfigInContextCode = 13388;
}
diff --git a/s/strategy.cpp b/s/strategy.cpp
index d94921f6433..c635792cf22 100644
--- a/s/strategy.cpp
+++ b/s/strategy.cpp
@@ -137,6 +137,7 @@ namespace mongo {
}
Request r( m , 0 );
+ r.init();
r.process();
}
else {
diff --git a/s/util.h b/s/util.h
index ebb559e2aac..e44318f221e 100644
--- a/s/util.h
+++ b/s/util.h
@@ -28,8 +28,6 @@
namespace mongo {
- extern const int StaleConfigInContextCode;
-
struct ShardChunkVersion {
union {
struct {
diff --git a/util/assert_util.h b/util/assert_util.h
index d1c8a0912c2..018dc43b551 100644
--- a/util/assert_util.h
+++ b/util/assert_util.h
@@ -22,6 +22,11 @@
namespace mongo {
+ enum CommonErrorCodes {
+ DatabaseDifferCaseCode = 13297 ,
+ StaleConfigInContextCode = 13388
+ };
+
/* these are manipulated outside of mutexes, so be careful */
struct Assertion {
Assertion() {