summaryrefslogtreecommitdiff
path: root/src/mongo/s/chunk_manager.cpp
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-08-06 13:26:55 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-08-12 11:27:43 -0400
commitbe7db282c80c981882ea67f909eb6be4e53d2d4b (patch)
tree615bcfdcc2e25e5db24b4d82f3db7cff1f9c4f91 /src/mongo/s/chunk_manager.cpp
parent86a3e6352eb27fd2e6115299bcec5103a830fe36 (diff)
downloadmongo-be7db282c80c981882ea67f909eb6be4e53d2d4b.tar.gz
SERVER-19543 Thread OperationContext through to everywhere that accesses the CatalogManager
Diffstat (limited to 'src/mongo/s/chunk_manager.cpp')
-rw-r--r--src/mongo/s/chunk_manager.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mongo/s/chunk_manager.cpp b/src/mongo/s/chunk_manager.cpp
index b200ce4e482..638935ddbf5 100644
--- a/src/mongo/s/chunk_manager.cpp
+++ b/src/mongo/s/chunk_manager.cpp
@@ -172,7 +172,7 @@ ChunkManager::ChunkManager(const CollectionType& coll)
_version = ChunkVersion::fromBSON(coll.toBSON());
}
-void ChunkManager::loadExistingRanges(const ChunkManager* oldManager) {
+void ChunkManager::loadExistingRanges(OperationContext* txn, const ChunkManager* oldManager) {
int tries = 3;
while (tries--) {
@@ -182,7 +182,7 @@ void ChunkManager::loadExistingRanges(const ChunkManager* oldManager) {
Timer t;
- bool success = _load(chunkMap, shardIds, &shardVersions, oldManager);
+ bool success = _load(txn, chunkMap, shardIds, &shardVersions, oldManager);
if (success) {
log() << "ChunkManager: time to load chunks for " << _ns << ": " << t.millis() << "ms"
<< " sequenceNumber: " << _sequenceNumber << " version: " << _version.toString()
@@ -215,7 +215,8 @@ void ChunkManager::loadExistingRanges(const ChunkManager* oldManager) {
<< " after 3 attempts. Please try again.");
}
-bool ChunkManager::_load(ChunkMap& chunkMap,
+bool ChunkManager::_load(OperationContext* txn,
+ ChunkMap& chunkMap,
set<ShardId>& shardIds,
ShardVersionMap* shardVersions,
const ChunkManager* oldManager) {
@@ -262,7 +263,7 @@ bool ChunkManager::_load(ChunkMap& chunkMap,
std::vector<ChunkType> chunks;
uassertStatusOK(
- grid.catalogManager()->getChunks(diffQuery.query, diffQuery.sort, boost::none, &chunks));
+ grid.catalogManager(txn)->getChunks(diffQuery.query, diffQuery.sort, boost::none, &chunks));
int diffsApplied = differ.calculateConfigDiff(chunks);
if (diffsApplied > 0) {
@@ -317,12 +318,12 @@ bool ChunkManager::_load(ChunkMap& chunkMap,
}
}
-shared_ptr<ChunkManager> ChunkManager::reload(bool force) const {
+shared_ptr<ChunkManager> ChunkManager::reload(OperationContext* txn, bool force) const {
const NamespaceString nss(_ns);
- auto status = grid.catalogCache()->getDatabase(nss.db().toString());
+ auto status = grid.catalogCache()->getDatabase(txn, nss.db().toString());
shared_ptr<DBConfig> config = uassertStatusOK(status);
- return config->getChunkManager(getns(), force);
+ return config->getChunkManager(txn, getns(), force);
}
void ChunkManager::_printChunks() const {
@@ -385,7 +386,8 @@ void ChunkManager::calcInitSplitsAndShards(const ShardId& primaryShardId,
}
}
-void ChunkManager::createFirstChunks(const ShardId& primaryShardId,
+void ChunkManager::createFirstChunks(OperationContext* txn,
+ const ShardId& primaryShardId,
const vector<BSONObj>* initPoints,
const set<ShardId>* initShardIds) {
// TODO distlock?
@@ -417,7 +419,7 @@ void ChunkManager::createFirstChunks(const ShardId& primaryShardId,
BSONObj chunkObj = chunkBuilder.obj();
- Status result = grid.catalogManager()->update(
+ Status result = grid.catalogManager(txn)->update(
ChunkType::ConfigNS, BSON(ChunkType::name(temp.genID())), chunkObj, true, false, NULL);
version.incMinor();
@@ -433,7 +435,7 @@ void ChunkManager::createFirstChunks(const ShardId& primaryShardId,
_version = ChunkVersion(0, 0, version.epoch());
}
-ChunkPtr ChunkManager::findIntersectingChunk(const BSONObj& shardKey) const {
+ChunkPtr ChunkManager::findIntersectingChunk(OperationContext* txn, const BSONObj& shardKey) const {
{
BSONObj chunkMin;
ChunkPtr chunk;
@@ -454,7 +456,7 @@ ChunkPtr ChunkManager::findIntersectingChunk(const BSONObj& shardKey) const {
log() << *chunk;
log() << shardKey;
- reload();
+ reload(txn);
msgasserted(13141, "Chunk map pointed to incorrect chunk");
}
}