Permalink
Browse files

Merge branch 'master' of github.com:mongodb/mongo

  • Loading branch information...
2 parents 292cf88 + 36c2946 commit 398b2aac8fe2354a2c6727c79bfcee4a9cbfe823 @dwight dwight committed Oct 27, 2010
Showing with 36 additions and 25 deletions.
  1. +1 −1 db/oplog.cpp
  2. +13 −0 db/repl/consensus.cpp
  3. +3 −3 dbtests/updatetests.cpp
  4. +2 −2 jstests/cursora.js
  5. +3 −7 s/balance.cpp
  6. +9 −7 s/chunk.cpp
  7. +2 −2 s/chunk.h
  8. +1 −1 s/d_logic.h
  9. +2 −2 s/d_split.cpp
View
@@ -359,7 +359,7 @@ namespace mongo {
}
log() << "******" << endl;
- log() << "creating replication oplog of size: " << (int)( sz / ( 1024 * 1024 ) ) << "MB... (use --oplogSize to change)" << endl;
+ log() << "creating replication oplog of size: " << (int)( sz / ( 1024 * 1024 ) ) << "MB..." << endl;
b.append("size", sz);
b.appendBool("capped", 1);
View
@@ -134,6 +134,9 @@ namespace mongo {
OID round = cmd["round"].OID();
int myver = rs.config().version;
+ const Member* primary = rs.box.getPrimary();
+ const Member* hopeful = rs.findById(whoid);
+
int vote = 0;
if( set != rs.name() ) {
log() << "replSet error received an elect request for '" << set << "' but our set name is '" << rs.name() << "'" << rsLog;
@@ -147,6 +150,16 @@ namespace mongo {
log() << "replSet info got stale version # during election" << rsLog;
vote = -10000;
}
+ else if( !hopeful ) {
+ log() << "couldn't find member with id " << whoid << rsLog;
+ vote = -10000;
+ }
+ else if( primary && primary->hbinfo().opTime > hopeful->hbinfo().opTime ) {
+ // other members might be aware of more up-to-date nodes
+ log() << hopeful->fullName() << " is trying to elect itself but " <<
+ primary->fullName() << " is already primary and more up-to-date" << rsLog;
+ vote = -10000;
+ }
else {
try {
vote = yea(whoid);
View
@@ -753,9 +753,9 @@ namespace UpdateTests {
client().insert( ns() , BSON( "x" << 5 ) );
ASSERT( findOne()["x"].type() == NumberInt );
long long start = 5;
- long long max = 1024L * 1024L * 1024L * 16;
- ASSERT( max > numeric_limits<int>::max() );
- cout << "E: " << max << endl;
+ long long max = numeric_limits<int>::max();
+ max *= 32;
+
while ( start < max ){
update( BSON( "$inc" << BSON( "x" << 500000 ) ) );
start += 500000;
View
@@ -21,8 +21,8 @@ function run( n , atomic ){
join()
print( "num: " + num + " time:" + ( end.getTime() - start.getTime() ) )
- assert.eq( 0 , t.count() , "after remove" )
- assert.lt( 0 , ex.nYields , "not enough yields" )
+ assert.eq( 0 , t.count() , "after remove: " + tojson( ex ) )
+ assert.lt( 0 , ex.nYields , "not enough yields : " + tojson( ex ) )
if ( n == num )
print( "warning: shouldn't have counted all n: " + n + " num: " + num );
}
View
@@ -73,13 +73,9 @@ namespace mongo {
continue;
}
- log() << "MOVE FAILED **** " << res << "\n"
- << " from: " << chunkInfo.from << " to: " << chunkInfo.to << " chunk: " << chunkToMove << endl;
-
- if ( res["split"].trueValue() ) {
- log() << "move asked for a split of " << c << endl;
- c->singleSplit( true /* force a split even if not enough data */ );
- }
+ // the move requires acquiring the collection metadata's lock, which can fail
+ log() << "balacer move failed: " << res << " from: " << chunkInfo.from << " to: " << chunkInfo.to
+ << " chunk: " << chunkToMove << endl;
}
return movedCount;
View
@@ -283,17 +283,17 @@ namespace mongo {
return ChunkPtr();
}
+ //return multiSplit_DEPRECATED( splitPoint );
return multiSplit( splitPoint );
- //return multiSplit_ForDevOnly( splitPoint );
}
- ChunkPtr Chunk::multiSplit_ForDevOnly( const vector<BSONObj>& m ) {
+ ChunkPtr Chunk::multiSplit( const vector<BSONObj>& m ) {
// TODO use current multiSplit asserts here
ScopedDbConnection conn( getShard().getConnString() );
BSONObj result;
BSONObjBuilder cmd;
- cmd.append( "splitChunk_ForDevOnly" , _manager->getns() );
+ cmd.append( "splitChunk" , _manager->getns() );
cmd.append( "keyPattern" , _manager->getShardKey().key() );
cmd.append( "min" , getMin() );
cmd.append( "max" , getMax() );
@@ -329,8 +329,7 @@ namespace mongo {
return _manager->findChunk( m[0] );
}
- /* to be deprecated */
- ChunkPtr Chunk::multiSplit( const vector<BSONObj>& m ){
+ ChunkPtr Chunk::multiSplit_DEPRECATED( const vector<BSONObj>& m ){
dist_lock_try dlk( &_manager->_nsLock , string("split-") + toString() );
uassert( 10166 , "locking namespace failed" , dlk.got() );
@@ -519,7 +518,7 @@ namespace mongo {
} catch ( std::exception& e ){
// if the collection lock is taken (e.g. we're migrating), it is fine for the split to fail.
- log() << "splitIfShould failed: " << e.what() << endl;
+ log() << "autosplit failed: " << e.what() << endl;
return false;
}
@@ -1030,7 +1029,10 @@ namespace mongo {
}
void ChunkManager::save_inlock( bool major ){
-
+ // we do not update update the chunk manager on the mongos side any more
+ // the only exception case should be first chunk creation
+ assert( _chunkMap.size() == 1 );
+
ShardChunkVersion version = getVersion_inlock();
assert( version > 0 || _chunkMap.size() <= 1 );
ShardChunkVersion nextChunkVersion = version;
View
@@ -124,8 +124,8 @@ namespace mongo {
* @param splitPoints the vector of keys that should be used to divide this chunk
* @return shared pointer to the first new Chunk
*/
- /* to be deprecated */ ChunkPtr multiSplit( const vector<BSONObj>& splitPoints );
- ChunkPtr multiSplit_ForDevOnly( const vector<BSONObj>& splitPoints );
+ ChunkPtr multiSplit_DEPRECATED( const vector<BSONObj>& splitPoints );
+ ChunkPtr multiSplit( const vector<BSONObj>& splitPoints );
/**
* Asks the mongod holding this chunk to find a key that approximately divides this chunk in two
View
@@ -95,7 +95,7 @@ namespace mongo {
// map from a namespace into the highest ShardChunkVersion for that collection
NSVersionMap _versions;
- // map from a namespace into the ensemble of chunk ranges that are stores in this mongod
+ // map from a namespace into the ensemble of chunk ranges that are stored in this mongod
map<string,ChunkMatcherPtr> _chunks;
};
View
@@ -372,10 +372,10 @@ namespace mongo {
class SplitChunkCommand : public Command {
public:
- SplitChunkCommand() : Command( "splitChunk_ForDevOnly" ){}
+ SplitChunkCommand() : Command( "splitChunk" ){}
virtual void help( stringstream& help ) const {
help <<
- "internal command ** under development ** \n"
+ "internal command usage only\n"
"example:\n"
" { splitChunk:\"db.foo\" , keyPattern: {a:1} , min : {a:100} , max: {a:200} { splitKeys : [ {a:150} , ... ]}";
}

0 comments on commit 398b2aa

Please sign in to comment.