summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2020-06-11 16:20:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-29 13:45:28 +0000
commit578ebc515122de8ed50b2b914d9d92ee61139b3f (patch)
tree70423886d40cf37be010be424e9c97a95cd35a8f /src
parent1c557517628311229f22388499eaf1c809169c32 (diff)
downloadmongo-578ebc515122de8ed50b2b914d9d92ee61139b3f.tar.gz
SERVER-48601 ChunkSplitter should use the same chunk bounds for splitVector and splitChunk
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/s/chunk_splitter.cpp12
-rw-r--r--src/mongo/s/chunk.h4
2 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/s/chunk_splitter.cpp b/src/mongo/db/s/chunk_splitter.cpp
index e6cfdf7f50e..6829a678542 100644
--- a/src/mongo/db/s/chunk_splitter.cpp
+++ b/src/mongo/db/s/chunk_splitter.cpp
@@ -305,7 +305,17 @@ void ChunkSplitter::_runAutosplit(std::shared_ptr<ChunkSplitStateDriver> chunkSp
"Could not split chunk. Collection is no longer sharded",
cm);
+ // Best effort checks that the chunk we're splitting hasn't changed bounds or moved shards
+ // since the auto split task was scheduled. Best effort because the chunk metadata may
+ // change after this point.
const auto chunk = cm->findIntersectingChunkWithSimpleCollation(min);
+ uassert(4860100,
+ "Chunk to be auto split has different boundaries than when the split was initiated",
+ chunk.getRange() == ChunkRange(min, max));
+ uassert(4860101,
+ "Chunk to be auto split isn't owned by this shard",
+ ShardingState::get(opCtx.get())->shardId() == chunk.getShardId());
+
const auto& shardKeyPattern = cm->getShardKeyPattern();
const auto balancerConfig = Grid::get(opCtx.get())->getBalancerConfiguration();
@@ -386,7 +396,7 @@ void ChunkSplitter::_runAutosplit(std::shared_ptr<ChunkSplitStateDriver> chunkSp
nss,
shardKeyPattern,
cm->getVersion(),
- ChunkRange(min, max),
+ chunk.getRange(),
splitPoints));
chunkSplitStateDriver->commitSplit();
diff --git a/src/mongo/s/chunk.h b/src/mongo/s/chunk.h
index e238809d248..77222f92408 100644
--- a/src/mongo/s/chunk.h
+++ b/src/mongo/s/chunk.h
@@ -143,6 +143,10 @@ public:
return _chunkInfo.getShardIdAt(_atClusterTime);
}
+ const auto& getRange() const {
+ return _chunkInfo.getRange();
+ }
+
/**
* Throws MigrationConflict if the history entry valid for the chunk's pinned cluster time, if
* it has one, is not the most recent entry (meaning the chunk has moved).