Permalink
Browse files

reloading a ChunkManager should also increment it sequence number

  • Loading branch information...
1 parent ba7cfbb commit a22cc7e48d666b0c8b5cdcaa4321addbd5f08653 Alberto Lerner committed Oct 27, 2010
Showing with 10 additions and 4 deletions.
  1. +8 −4 s/chunk.cpp
  2. +2 −0 s/shard_version.cpp
View
@@ -695,10 +695,9 @@ namespace mongo {
ChunkManager::ChunkManager( DBConfig * config , string ns , ShardKeyPattern pattern , bool unique ) :
_config( config ) , _ns( ns ) ,
_key( pattern ) , _unique( unique ) ,
- _sequenceNumber( ++NextSequenceNumber ),
_lock("rw:ChunkManager"), _nsLock( ConnectionString( configServer.modelServer() , ConnectionString::SYNC ) , ns )
{
- _reload_inlock();
+ _reload_inlock(); // will set _sequenceNumber
}
ChunkManager::~ChunkManager(){
@@ -722,15 +721,20 @@ namespace mongo {
if (_isValid()){
_chunkRanges.reloadAll(_chunkMap);
+
+ // The shard versioning mechanism hinges on keeping track of the number of times we reloaded ChunkManager's.
+ // Increasing this number here will prompt checkShardVersion() to refresh the connection-level versions to
+ // the most up to date value.
+ _sequenceNumber = ++NextSequenceNumber;
+
return;
}
if (_chunkMap.size() < 10){
_printChunks();
}
- // TODO which one is it? millis or secs?
+
sleepmillis(10 * (3-tries));
- sleepsecs(10);
}
msgasserted(13282, "Couldn't load a valid config for " + _ns + " after 3 attempts. Please try again.");
View
@@ -97,6 +97,8 @@ namespace mongo {
officialSequenceNumber = manager->getSequenceNumber();
}
+ // has the ChunkManager been reloaded since the last time we updated the connection-level version?
+ // (ie, last time we issued the setShardVersions below)
unsigned long long sequenceNumber = connectionShardStatus.getSequence(&conn,ns);
if ( sequenceNumber == officialSequenceNumber ){
return false;

0 comments on commit a22cc7e

Please sign in to comment.