Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SERVER-4171 check in wbl for newly sharded state, reload

  • Loading branch information...
commit a8deef409a7319faafa4d746881bcaac31ee061c 1 parent 0524f59
Greg Studer authored
Showing with 23 additions and 5 deletions.
  1. +10 −0 s/config.cpp
  2. +1 −0  s/config.h
  3. +12 −5 s/writeback_listener.cpp
View
10 s/config.cpp
@@ -211,6 +211,16 @@ namespace mongo {
return true;
}
+ ChunkManagerPtr DBConfig::getChunkManagerIfExists( const string& ns, bool shouldReload ){
+ try{
+ return getChunkManager( ns, shouldReload );
+ }
+ catch( AssertionException& e ){
+ warning() << "chunk manager not found for " << ns << " :: caused by :: " << e.toString() << endl;
+ return ChunkManagerPtr();
+ }
+ }
+
ChunkManagerPtr DBConfig::getChunkManager( const string& ns , bool shouldReload ) {
scoped_lock lk( _lock );
View
1  s/config.h
@@ -132,6 +132,7 @@ namespace mongo {
*/
bool isSharded( const string& ns );
+ ChunkManagerPtr getChunkManagerIfExists( const string& ns , bool reload = false );
ChunkManagerPtr getChunkManager( const string& ns , bool reload = false );
/**
View
17 s/writeback_listener.cpp
@@ -162,14 +162,16 @@ namespace mongo {
DBConfigPtr db = grid.getDBConfig( ns );
ShardChunkVersion needVersion( data["version"] );
+ ChunkManagerPtr manager = db->getChunkManagerIfExists( ns );
+
LOG(1) << "connectionId: " << cid << " writebackId: " << wid << " needVersion : " << needVersion.toString()
- << " mine : " << db->getChunkManager( ns )->getVersion().toString() << endl;// TODO change to log(3)
+ << " mine : " << ( manager ? manager->getVersion().toString() : "(none)" ) << endl;// TODO change to log(3)
if ( logLevel ) log(1) << debugString( m ) << endl;
- ShardChunkVersion start = db->getChunkManager( ns )->getVersion();
+ ShardChunkVersion start = ( manager ? manager->getVersion() : (ShardChunkVersion)0 );
- if ( needVersion.isSet() && needVersion <= start ) {
+ if ( manager && needVersion.isSet() && needVersion <= start ) {
// this means when the write went originally, the version was old
// if we're here, it means we've already updated the config, so don't need to do again
//db->getChunkManager( ns , true ); // SERVER-1349
@@ -180,11 +182,16 @@ namespace mongo {
// we need to reload the chunk manager and get the new shard versions
bool good = false;
for ( int i=0; i<100; i++ ) {
- if ( db->getChunkManager( ns , true )->getVersion() >= needVersion ) {
+ manager = db->getChunkManagerIfExists( ns , true );
+ if( ! manager && needVersion == 0 ){
+ good = true;
+ break;
+ }
+ else if ( manager->getVersion() >= needVersion ) {
good = true;
break;
}
- log() << "writeback getChunkManager didn't update?" << endl;
+ log() << "chunk manager didn't update in writeback listener, wanted version : " << needVersion << ", found : " << ( manager ? manager->getVersion().toString() : "(none)" ) << endl;
sleepmillis(10);
}
assert( good );
Please sign in to comment.
Something went wrong with that request. Please try again.