diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-09-22 17:10:33 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-09-22 17:12:39 -0400 |
commit | e95a0838de334600dca1322914601b4b8404667b (patch) | |
tree | 40c30f393bba4563308bc18894a9a6e1faa35b2f /src/mongo/db/s | |
parent | 6d6347195a57c71769b34615a7641e23f2af33c8 (diff) | |
download | mongo-e95a0838de334600dca1322914601b4b8404667b.tar.gz |
SERVER-19934 Fix usage of ShardRegistry before sharding is initialized'
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r-- | src/mongo/db/s/migration_impl.cpp | 19 | ||||
-rw-r--r-- | src/mongo/db/s/move_chunk_command.cpp | 6 |
2 files changed, 9 insertions, 16 deletions
diff --git a/src/mongo/db/s/migration_impl.cpp b/src/mongo/db/s/migration_impl.cpp index 8089d1a9b35..b909a50227b 100644 --- a/src/mongo/db/s/migration_impl.cpp +++ b/src/mongo/db/s/migration_impl.cpp @@ -328,15 +328,6 @@ Status ChunkMoveOperationState::commitMigration(OperationContext* txn) { log() << "moveChunk migrate commit accepted by TO-shard: " << res << migrateLog; - // Version at which the next highest lastmod will be set. If the chunk being moved is the - // last in the shard, nextVersion is that chunk's lastmod otherwise the highest version is - // from the chunk being bumped on the FROM-shard. - ChunkVersion nextVersion; - - // We want to go only once to the configDB but perhaps change two chunks, the one being - // migrated and another local one (so to bump version for the entire shard) we use the - // 'applyOps' mechanism to group the two updates and make them safer. - BSONArrayBuilder updates; { @@ -362,11 +353,13 @@ Status ChunkMoveOperationState::commitMigration(OperationContext* txn) { updates.append(op.obj()); } - nextVersion = myVersion; - - // If we have chunks left on the FROM shard, update the version of one of them as well. We - // can figure that out by grabbing the metadata as it has been changed. + // Version at which the next highest lastmod will be set. If the chunk being moved is the last + // in the shard, nextVersion is that chunk's lastmod otherwise the highest version is from the + // chunk being bumped on the FROM-shard. + ChunkVersion nextVersion = myVersion; + // If we have chunks left on the FROM shard, update the version of one of them as well. We can + // figure that out by grabbing the metadata as it has been changed. const std::shared_ptr<CollectionMetadata> bumpedCollMetadata( shardingState->getCollectionMetadata(_nss.ns())); if (bumpedCollMetadata->getNumChunks() > 0) { diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp index bd5dc19b725..80ff93c8186 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -186,9 +186,6 @@ public: result, Status(ErrorCodes::InvalidOptions, "need to specify namespace in command")); } - ChunkMoveOperationState chunkMoveState{NamespaceString(ns)}; - uassertStatusOK(chunkMoveState.initialize(txn, cmdObj)); - ShardingState* const shardingState = ShardingState::get(txn); // This could be the first call that enables sharding - make sure we initialize the @@ -204,6 +201,9 @@ public: shardingState->initialize(txn, configdb); } + ChunkMoveOperationState chunkMoveState{NamespaceString(ns)}; + uassertStatusOK(chunkMoveState.initialize(txn, cmdObj)); + // Initialize our current shard name in the shard state if needed shardingState->setShardName(chunkMoveState.getFromShard()); |