mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-17586 Update ShardVersionMap in ChunkManager when shard is deleted during balancing
This commit is contained in:
parent
63cdeb9c56
commit
465ca1774d
@ -158,7 +158,7 @@ namespace {
|
|||||||
ShardVersionMap shardVersions;
|
ShardVersionMap shardVersions;
|
||||||
Timer t;
|
Timer t;
|
||||||
|
|
||||||
bool success = _load(config, chunkMap, shards, shardVersions, oldManager);
|
bool success = _load(config, chunkMap, shards, &shardVersions, oldManager);
|
||||||
|
|
||||||
if( success ){
|
if( success ){
|
||||||
{
|
{
|
||||||
@ -201,7 +201,7 @@ namespace {
|
|||||||
bool ChunkManager::_load(const string& config,
|
bool ChunkManager::_load(const string& config,
|
||||||
ChunkMap& chunkMap,
|
ChunkMap& chunkMap,
|
||||||
set<Shard>& shards,
|
set<Shard>& shards,
|
||||||
ShardVersionMap& shardVersions,
|
ShardVersionMap* shardVersions,
|
||||||
const ChunkManager* oldManager)
|
const ChunkManager* oldManager)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ namespace {
|
|||||||
// Get the old max version
|
// Get the old max version
|
||||||
_version = oldManager->getVersion();
|
_version = oldManager->getVersion();
|
||||||
// Load a copy of the old versions
|
// Load a copy of the old versions
|
||||||
shardVersions = oldManager->_shardVersions;
|
*shardVersions = oldManager->_shardVersions;
|
||||||
|
|
||||||
// Load a copy of the chunk map, replacing the chunk manager with our own
|
// Load a copy of the chunk map, replacing the chunk manager with our own
|
||||||
const ChunkMap& oldChunkMap = oldManager->getChunkMap();
|
const ChunkMap& oldChunkMap = oldManager->getChunkMap();
|
||||||
@ -243,7 +243,7 @@ namespace {
|
|||||||
|
|
||||||
// Attach a diff tracker for the versioned chunk data
|
// Attach a diff tracker for the versioned chunk data
|
||||||
CMConfigDiffTracker differ( this );
|
CMConfigDiffTracker differ( this );
|
||||||
differ.attach( _ns, chunkMap, _version, shardVersions );
|
differ.attach( _ns, chunkMap, _version, *shardVersions );
|
||||||
|
|
||||||
// Diff tracker should *always* find at least one chunk if collection exists
|
// Diff tracker should *always* find at least one chunk if collection exists
|
||||||
int diffsApplied = differ.calculateConfigDiff(config);
|
int diffsApplied = differ.calculateConfigDiff(config);
|
||||||
@ -252,9 +252,17 @@ namespace {
|
|||||||
LOG(2) << "loaded " << diffsApplied << " chunks into new chunk manager for " << _ns
|
LOG(2) << "loaded " << diffsApplied << " chunks into new chunk manager for " << _ns
|
||||||
<< " with version " << _version;
|
<< " with version " << _version;
|
||||||
|
|
||||||
// Add all the shards we find to the shards set
|
// Add all existing shards we find to the shards set
|
||||||
for( ShardVersionMap::iterator it = shardVersions.begin(); it != shardVersions.end(); it++ ){
|
for (ShardVersionMap::iterator it = shardVersions->begin();
|
||||||
shards.insert( it->first );
|
it != shardVersions->end();
|
||||||
|
) {
|
||||||
|
if (Shard::findIfExists(it->first).ok()) {
|
||||||
|
shards.insert(it->first);
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
shardVersions->erase(it++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -267,7 +275,7 @@ namespace {
|
|||||||
|
|
||||||
// Set all our data to empty
|
// Set all our data to empty
|
||||||
chunkMap.clear();
|
chunkMap.clear();
|
||||||
shardVersions.clear();
|
shardVersions->clear();
|
||||||
_version = ChunkVersion( 0, 0, OID() );
|
_version = ChunkVersion( 0, 0, OID() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -291,7 +299,7 @@ namespace {
|
|||||||
|
|
||||||
// Set all our data to empty to be extra safe
|
// Set all our data to empty to be extra safe
|
||||||
chunkMap.clear();
|
chunkMap.clear();
|
||||||
shardVersions.clear();
|
shardVersions->clear();
|
||||||
_version = ChunkVersion( 0, 0, OID() );
|
_version = ChunkVersion( 0, 0, OID() );
|
||||||
|
|
||||||
return allInconsistent;
|
return allInconsistent;
|
||||||
|
@ -224,7 +224,7 @@ namespace mongo {
|
|||||||
bool _load(const std::string& config,
|
bool _load(const std::string& config,
|
||||||
ChunkMap& chunks,
|
ChunkMap& chunks,
|
||||||
std::set<Shard>& shards,
|
std::set<Shard>& shards,
|
||||||
ShardVersionMap& shardVersions,
|
ShardVersionMap* shardVersions,
|
||||||
const ChunkManager* oldManager);
|
const ChunkManager* oldManager);
|
||||||
static bool _isValid(const ChunkMap& chunks);
|
static bool _isValid(const ChunkMap& chunks);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user