diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-05-14 17:47:58 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-05-15 13:04:58 -0400 |
commit | e9c4cdcaf03d2a3828f21dd1d84eb69e7b91b204 (patch) | |
tree | f423eb35c7d4c2b760920ff88b507022c04e4c99 /src/mongo/s/d_migrate.cpp | |
parent | 62ca88a7e9e0e201050dcc9363b70ba5cd724040 (diff) | |
download | mongo-e9c4cdcaf03d2a3828f21dd1d84eb69e7b91b204.tar.gz |
SERVER-18124 Move 'newest chunk' check to the catalog manager
* Adds ability to specify limit to the chunk listing call.
* Gets rid of the getChunksForShard call since it can be built on getChunks
Diffstat (limited to 'src/mongo/s/d_migrate.cpp')
-rw-r--r-- | src/mongo/s/d_migrate.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index c443347fe87..b509b5b5784 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -1688,31 +1688,34 @@ namespace mongo { warning() << "moveChunk commit outcome ongoing" << migrateLog; sleepsecs( 10 ); + // look for the chunk in this shard whose version got bumped + // we assume that if that mod made it to the config, the applyOps was successful try { - ScopedDbConnection conn(shardingState.getConfigServer(), 10.0); - - // look for the chunk in this shard whose version got bumped - // we assume that if that mod made it to the config, the applyOps was successful - BSONObj doc = conn->findOne(ChunkType::ConfigNS, + std::vector<ChunkType> newestChunk; + Status status = grid.catalogManager()->getChunks( Query(BSON(ChunkType::ns(ns))) - .sort(BSON(ChunkType::DEPRECATED_lastmod() << -1))); - + .sort(ChunkType::DEPRECATED_lastmod(), -1), + 1, + &newestChunk); + uassertStatusOK(status); + + ChunkVersion checkVersion; + if (!newestChunk.empty()) { + invariant(newestChunk.size() == 1); + checkVersion = newestChunk[0].getVersion(); + } - ChunkVersion checkVersion(ChunkVersion::fromBSON(doc)); - if ( checkVersion.equals( nextVersion ) ) { + if (checkVersion.equals(nextVersion)) { log() << "moveChunk commit confirmed" << migrateLog; errmsg.clear(); } else { error() << "moveChunk commit failed: version is at " - << checkVersion << " instead of " << nextVersion << migrateLog; + << checkVersion << " instead of " << nextVersion << migrateLog; error() << "TERMINATING" << migrateLog; dbexit( EXIT_SHARDING_ERROR ); } - - conn.done(); - } catch ( ... ) { error() << "moveChunk failed to get confirmation of commit" << migrateLog; |