Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

reloading a ChunkManager should also increment it sequence number

  • Loading branch information...
commit a22cc7e48d666b0c8b5cdcaa4321addbd5f08653 1 parent ba7cfbb
authored October 27, 2010
12  s/chunk.cpp
@@ -695,10 +695,9 @@ namespace mongo {
695 695
     ChunkManager::ChunkManager( DBConfig * config , string ns , ShardKeyPattern pattern , bool unique ) : 
696 696
         _config( config ) , _ns( ns ) , 
697 697
         _key( pattern ) , _unique( unique ) , 
698  
-        _sequenceNumber(  ++NextSequenceNumber ), 
699 698
         _lock("rw:ChunkManager"), _nsLock( ConnectionString( configServer.modelServer() , ConnectionString::SYNC ) , ns )
700 699
     {
701  
-        _reload_inlock();
  700
+        _reload_inlock();  // will set _sequenceNumber
702 701
     }
703 702
 
704 703
     ChunkManager::~ChunkManager(){
@@ -722,15 +721,20 @@ namespace mongo {
722 721
 
723 722
             if (_isValid()){
724 723
                 _chunkRanges.reloadAll(_chunkMap);
  724
+
  725
+                // The shard versioning mechanism hinges on keeping track of the number of times we reloaded ChunkManager's.
  726
+                // Increasing this number here will prompt checkShardVersion() to refresh the connection-level versions to
  727
+                // the most up to date value.
  728
+                _sequenceNumber = ++NextSequenceNumber; 
  729
+
725 730
                 return;
726 731
             }
727 732
 
728 733
             if (_chunkMap.size() < 10){ 
729 734
                 _printChunks();
730 735
             }
731  
-            // TODO which one is it? millis or secs?
  736
+
732 737
             sleepmillis(10 * (3-tries));
733  
-            sleepsecs(10);
734 738
         }
735 739
 
736 740
         msgasserted(13282, "Couldn't load a valid config for " + _ns + " after 3 attempts. Please try again.");
2  s/shard_version.cpp
@@ -97,6 +97,8 @@ namespace mongo {
97 97
             officialSequenceNumber = manager->getSequenceNumber();
98 98
         }
99 99
 
  100
+        // has the ChunkManager been reloaded since the last time we updated the connection-level version?
  101
+        // (ie, last time we issued the setShardVersions below)
100 102
         unsigned long long sequenceNumber = connectionShardStatus.getSequence(&conn,ns);
101 103
         if ( sequenceNumber == officialSequenceNumber ){
102 104
             return false;

0 notes on commit a22cc7e

Please sign in to comment.
Something went wrong with that request. Please try again.