Skip to content

Commit

Permalink
SERVER-4987 if using sharded connections, always need to handle Stale…
Browse files Browse the repository at this point in the history
…ConfigExceptions
  • Loading branch information
Greg Studer committed Feb 24, 2012
1 parent 79a8b1e commit f8eee92
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/mongo/s/chunk.cpp
Expand Up @@ -109,6 +109,8 @@ namespace mongo {
}

BSONObj Chunk::_getExtremeKey( int sort ) const {
// We need to use a sharded connection here b/c there could be data left from stale migrations outside
// our chunk ranges.
ShardConnection conn( getShard().getConnString() , _manager->getns() );
Query q;
if ( sort == 1 ) {
Expand All @@ -132,8 +134,17 @@ namespace mongo {
}

// find the extreme key
BSONObj end = conn->findOne( _manager->getns() , q );
conn.done();
BSONObj end;
try {
end = conn->findOne( _manager->getns() , q );
conn.done();
}
catch( StaleConfigException& ){
// We need to handle stale config exceptions if using sharded connections
// caught and reported above
conn.done();
throw;
}

if ( end.isEmpty() )
return BSONObj();
Expand Down

0 comments on commit f8eee92

Please sign in to comment.