summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-04-03 14:38:16 -0400
committerAaron <aaron@10gen.com>2009-04-03 14:38:16 -0400
commit15abe0c3887c77d780ee6d9bae0731c04ab8bbb0 (patch)
tree34be9abf60b207b660aadb67e97180f1b7d16321
parentec5991e872043e7cefe65062e1a40847e0306ebf (diff)
parentdf3daad26f5986459f1a68302e74dbce75182420 (diff)
downloadmongo-15abe0c3887c77d780ee6d9bae0731c04ab8bbb0.tar.gz
Merge branch 'master' of git@github.com:mongodb/mongo
-rw-r--r--s/commands.cpp9
-rw-r--r--s/shard.cpp3
-rw-r--r--s/strategy.cpp13
-rw-r--r--s/strategy.h7
4 files changed, 22 insertions, 10 deletions
diff --git a/s/commands.cpp b/s/commands.cpp
index 3b58628606d..af053754546 100644
--- a/s/commands.cpp
+++ b/s/commands.cpp
@@ -339,15 +339,10 @@ namespace mongo {
log() << "splitting: " << ns << " shard: " << old << endl;
- unsigned long long nextTS = grid.getNextOpTime();
- ScopedDbConnection conn( old.getServer() );
- BSONObj lockResult;
- if ( ! setShardVersion( conn.conn() , ns , nextTS , true , lockResult ) ){
- log() << "setShardVersion for split failed!" << endl;
- errmsg = "setShardVersion failed to lock server. is someone else doing something?";
+ if ( ! lockNamespaceOnServer( old.getServer() , ns ) ){
+ log() << errmsg << endl;
return false;
}
- conn.done();
if ( middle.isEmpty() )
old.split();
diff --git a/s/shard.cpp b/s/shard.cpp
index 27c44f3727c..99e64ed3d1a 100644
--- a/s/shard.cpp
+++ b/s/shard.cpp
@@ -21,6 +21,7 @@
#include "config.h"
#include "../util/unittest.h"
#include "../client/connpool.h"
+#include "strategy.h"
namespace mongo {
@@ -126,6 +127,8 @@ namespace mongo {
string from = _server;
+ lockNamespaceOnServer( from , _ns );
+
// copyCollection
ScopedDbConnection toconn( to );
BSONObj cloneRes;
diff --git a/s/strategy.cpp b/s/strategy.cpp
index dc644cb86e7..6a252f68d30 100644
--- a/s/strategy.cpp
+++ b/s/strategy.cpp
@@ -106,5 +106,16 @@ namespace mongo {
return conn.runCommand( "admin" , cmd , result );
}
-
+
+ bool lockNamespaceOnServer( const string& server , const string& ns ){
+ ScopedDbConnection conn( server );
+ bool res = lockNamespaceOnServer( conn.conn() , ns );
+ conn.done();
+ return res;
+ }
+
+ bool lockNamespaceOnServer( DBClientBase& conn , const string& ns ){
+ BSONObj lockResult;
+ return setShardVersion( conn , ns , grid.getNextOpTime() , true , lockResult );
+ }
}
diff --git a/s/strategy.h b/s/strategy.h
index fbe0d50d058..88540fac4e0 100644
--- a/s/strategy.h
+++ b/s/strategy.h
@@ -24,11 +24,14 @@ namespace mongo {
};
+ extern Strategy * SINGLE;
+ extern Strategy * SHARDED;
+
void checkShardVersion( DBClientBase & conn , const string& ns , bool authoritative = false );
bool setShardVersion( DBClientBase & conn , const string& ns , ServerShardVersion version , bool authoritative , BSONObj& result );
- extern Strategy * SINGLE;
- extern Strategy * SHARDED;
+ bool lockNamespaceOnServer( const string& server , const string& ns );
+ bool lockNamespaceOnServer( DBClientBase& conn , const string& ns );
}