summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/s/collection_metadata.cpp4
-rw-r--r--src/mongo/s/commands/cluster_write.cpp6
2 files changed, 7 insertions, 3 deletions
diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp
index f9e1a32ac51..9813a45275b 100644
--- a/src/mongo/db/s/collection_metadata.cpp
+++ b/src/mongo/db/s/collection_metadata.cpp
@@ -170,7 +170,7 @@ Status CollectionMetadata::checkChunkIsValid(const ChunkType& chunk) {
ChunkType existingChunk;
if (!getNextChunk(chunk.getMin(), &existingChunk)) {
- return {ErrorCodes::IncompatibleShardingMetadata,
+ return {ErrorCodes::StaleShardVersion,
str::stream() << "Chunk with bounds "
<< ChunkRange(chunk.getMin(), chunk.getMax()).toString()
<< " is not owned by this shard."};
@@ -178,7 +178,7 @@ Status CollectionMetadata::checkChunkIsValid(const ChunkType& chunk) {
if (existingChunk.getMin().woCompare(chunk.getMin()) ||
existingChunk.getMax().woCompare(chunk.getMax())) {
- return {ErrorCodes::IncompatibleShardingMetadata,
+ return {ErrorCodes::StaleShardVersion,
str::stream() << "Unable to find chunk with the exact bounds "
<< ChunkRange(chunk.getMin(), chunk.getMax()).toString()
<< " at collection version "
diff --git a/src/mongo/s/commands/cluster_write.cpp b/src/mongo/s/commands/cluster_write.cpp
index cb3c5282252..0bc72d6fd7c 100644
--- a/src/mongo/s/commands/cluster_write.cpp
+++ b/src/mongo/s/commands/cluster_write.cpp
@@ -454,7 +454,11 @@ void updateChunkWriteStatsAndSplitIfNeeded(OperationContext* opCtx,
} catch (const DBException& ex) {
chunk->randomizeBytesWritten();
- log() << "Unable to auto-split chunk " << redact(chunkRange.toString()) << causedBy(ex);
+ if (ErrorCodes::isStaleShardingError(ErrorCodes::Error(ex.getCode()))) {
+ log() << "Unable to auto-split chunk " << redact(chunkRange.toString()) << causedBy(ex)
+ << ", going to invalidate routing table entry for " << nss;
+ Grid::get(opCtx)->catalogCache()->invalidateShardedCollection(nss);
+ }
}
}