Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
Fully Compatible
-
ALL
-
Sharding 14 (05/13/16), Sharding 15 (06/03/16)
Description
ShardRegistry::reload() is called in many places and internally it performs a call to CatalogManager::getAllShards() and then rebuilds all internal maps.
To encapsulate the reload functionality:
1) Add ShardRegistryData class (ShardRegistry eventually will get stripped of its other responsibilities and so ShardRegistryData can become what is ShardRegistry now)
2) Provide a helper method (pseudocode)
void ShardRegistryData::swap(ShardRegistryData* other) {
|
if (other->newerThan(this) {
|
// swap
|
}
|
}
|
|
|
shared_ptr<Shard> getShard(txn) {
|
auto shard = grid.shardResistry()->getShard();
|
if (!shard) {
|
ShardRegistryData newShardRegistry(txn);
|
grid.shardRegistry().data().swap(&newShardRegistry);
|
}
|
shard = grid.shardResistry()->getShard();
|
}
|
return shard;
|
}
|
3) replace calls to ShardRegistry::getShard() with the new method
4) Add a class ShardRegistryUpdater
owned by ShardRegistry that will be used to update ShardRegistryData via swap:
ShardRegistryData newShardRegistry(txn);
|
grid.shardRegistry().data().swap(&newShardRegistry);
|
Protect the calls with a lock to serialize the reload order.
5) In place of reload() use
grid.shardRegistry()->shardRegistryUpdater()->reload();
|