summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2017-06-16 16:15:45 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2017-06-20 14:25:05 -0400
commitd5e9b4994557285017795d9ed9129341314da202 (patch)
tree64f8ba2b6c9ed0f6a94dffefaccccf2cbc75ae08
parentf810e9a849cc98254a28e2f7c704785f2c8e0e6b (diff)
downloadmongo-d5e9b4994557285017795d9ed9129341314da202.tar.gz
SERVER-28418 make the split command on mongod return a stale version error if the requested chunk bounds are not foundr3.5.9
-rw-r--r--jstests/core/removeb.js5
-rw-r--r--src/mongo/db/s/collection_metadata.cpp4
-rw-r--r--src/mongo/s/commands/cluster_write.cpp6
3 files changed, 11 insertions, 4 deletions
diff --git a/jstests/core/removeb.js b/jstests/core/removeb.js
index 2141e138254..8d049e2439b 100644
--- a/jstests/core/removeb.js
+++ b/jstests/core/removeb.js
@@ -11,6 +11,9 @@ t.remove({});
// Insert some data.
for (i = 0; i < 20000; ++i) {
+ if (i % 100 == 0) {
+ print(i + " of first set of 20000 documents inserted");
+ }
t.insert({a: i});
}
@@ -23,7 +26,7 @@ p = startParallelShell(
'for( i = 20000; i < 40000; ++i ) {' +
' db.jstests_removeb.insert( { a:i } );' +
' if (i % 1000 == 0) {' +
- ' print( i-20000 + \" of 20000 documents inserted\" );' +
+ ' print( i-20000 + \" of second set of 20000 documents inserted\" );' +
' }' +
'}');
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);
+ }
}
}