Permalink
Browse files

split locking

  • Loading branch information...
1 parent fe27fdc commit 745cfbff47a94ccfbfea737d1b239aef3a875512 @erh erh committed Mar 30, 2009
Showing with 24 additions and 0 deletions.
  1. +11 −0 s/commands.cpp
  2. +10 −0 s/config.cpp
  3. +2 −0 s/config.h
  4. +1 −0 s/strategy.h
View
@@ -33,6 +33,7 @@
#include "config.h"
#include "shard.h"
+#include "strategy.h"
namespace mongo {
@@ -299,6 +300,16 @@ namespace mongo {
Shard& old = info->findShard( find );
log() << "splitting: " << ns << " on: " << find << 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?";
+ return false;
+ }
+ conn.done();
if ( middle )
old.split( cmdObj.getObjectField( "middle" ) );
View
@@ -199,6 +199,16 @@ namespace mongo {
return cc;
}
+ unsigned long long Grid::getNextOpTime() const {
+ ScopedDbConnection conn( configServer.getPrimary() );
+
+ BSONObj result;
+ massert( "getoptime failed" , conn->simpleCommand( "admin" , &result , "getoptime" ) );
+ conn.done();
+
+ return result["optime"].date();
+ }
+
/* --- ConfigServer ---- */
ConfigServer::ConfigServer() {
View
@@ -113,6 +113,8 @@ namespace mongo {
string pickServerForNewDB();
bool knowAboutServer( string name ) const;
+
+ unsigned long long getNextOpTime() const;
private:
map<string,DBConfig*> _databases;
};
View
@@ -4,6 +4,7 @@
#include "stdafx.h"
#include "shard.h"
+#include "request.h"
namespace mongo {

0 comments on commit 745cfbf

Please sign in to comment.