diff options
| author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-02-13 21:23:58 -0500 |
|---|---|---|
| committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-02-21 20:29:44 -0500 |
| commit | 3157be3048cdeb676579ed0d860d8416cb8c4667 (patch) | |
| tree | 28f394aa73a164127165c880bc9b57b94354f718 /src/mongo/db/s/split_chunk.cpp | |
| parent | 74d11ae8949bb795c6fc56a56a7bb1ed64a7eb79 (diff) | |
| download | mongo-3157be3048cdeb676579ed0d860d8416cb8c4667.tar.gz | |
SERVER-29908 Move stale shard version handling out of ShardingState
Diffstat (limited to 'src/mongo/db/s/split_chunk.cpp')
| -rw-r--r-- | src/mongo/db/s/split_chunk.cpp | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/src/mongo/db/s/split_chunk.cpp b/src/mongo/db/s/split_chunk.cpp index c8c9015a1d3..1936edb3ff4 100644 --- a/src/mongo/db/s/split_chunk.cpp +++ b/src/mongo/db/s/split_chunk.cpp @@ -44,6 +44,7 @@ #include "mongo/db/query/internal_plans.h" #include "mongo/db/s/collection_metadata.h" #include "mongo/db/s/collection_sharding_state.h" +#include "mongo/db/s/shard_filtering_metadata_refresh.h" #include "mongo/db/s/sharding_state.h" #include "mongo/s/catalog/type_chunk.h" #include "mongo/s/client/shard_registry.h" @@ -131,10 +132,6 @@ StatusWith<boost::optional<ChunkRange>> splitChunk(OperationContext* opCtx, const std::vector<BSONObj>& splitKeys, const std::string& shardName, const OID& expectedCollectionEpoch) { - - ShardingState* shardingState = ShardingState::get(opCtx); - std::string errmsg; - // // Lock the collection's metadata and get highest version for the current shard // TODO(SERVER-25086): Remove distLock acquisition from split chunk @@ -158,12 +155,13 @@ StatusWith<boost::optional<ChunkRange>> splitChunk(OperationContext* opCtx, while (it.more()) { BSONElement splitKeyElement = it.next(); if (splitKeyElement.type() != NumberLong) { - errmsg = str::stream() << "splitChunk cannot split chunk " - << chunkRange.toString() << ", split point " - << splitKeyElement.toString() - << " must be of type " - "NumberLong for hashed shard key patterns"; - return {ErrorCodes::CannotSplit, errmsg}; + return {ErrorCodes::CannotSplit, + str::stream() << "splitChunk cannot split chunk " + << chunkRange.toString() + << ", split point " + << splitKeyElement.toString() + << " must be of type " + "NumberLong for hashed shard key patterns"}; } } } @@ -206,23 +204,7 @@ StatusWith<boost::optional<ChunkRange>> splitChunk(OperationContext* opCtx, // succeeds, thus the automatic retry fails with a precondition violation, for example. // if (!commandStatus.isOK() || !writeConcernStatus.isOK()) { - { - ChunkVersion unusedShardVersion; - Status refreshStatus = - shardingState->refreshMetadataNow(opCtx, nss, &unusedShardVersion); - - if (!refreshStatus.isOK()) { - Status errorStatus = commandStatus.isOK() ? writeConcernStatus : commandStatus; - errmsg = str::stream() - << "splitChunk failed for chunk " << chunkRange.toString() << ", collection '" - << nss.ns() << "' due to " << errorStatus.toString() - << ". Attempt to verify if the commit succeeded anyway failed due to: " - << refreshStatus.toString(); - - warning() << redact(errmsg); - return errorStatus.withReason(errmsg); - } - } + forceShardFilteringMetadataRefresh(opCtx, nss); if (checkMetadataForSuccessfulSplitChunk(opCtx, nss, chunkRange, splitKeys)) { // Split was committed. |
