mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-74770 Make sure that analyzeShardKey command never insert a split point document more than once
This commit is contained in:
parent
a56ab1d23f
commit
d8e828f669
@ -75,7 +75,7 @@ function makeAnalyzeShardKeyAggregateCmdObj(st, collName, key, splitPointsShardI
|
||||
makeAnalyzeShardKeyAggregateCmdObj(st, validationTest.collName, {b: 1}, st.shard0.name);
|
||||
const splitPointsColl = shard0Primary.getCollection(
|
||||
aggCmdObj.pipeline[0]["$_analyzeShardKeyReadWriteDistribution"].splitPointsNss);
|
||||
assert.commandWorked(splitPointsColl.insert({splitPoint: {b: [0, 0]}}));
|
||||
assert.commandWorked(splitPointsColl.insert({_id: UUID(), splitPoint: {b: [0, 0]}}));
|
||||
assert.commandFailedWithCode(
|
||||
shard0Primary.getDB(validationTest.dbName).runCommand(aggCmdObj), ErrorCodes.BadValue);
|
||||
splitPointsColl.drop();
|
||||
@ -88,7 +88,7 @@ function makeAnalyzeShardKeyAggregateCmdObj(st, collName, key, splitPointsShardI
|
||||
makeAnalyzeShardKeyAggregateCmdObj(st, validationTest.collName, {a: 1}, st.shard0.name);
|
||||
const splitPointsColl = shard0Primary.getCollection(
|
||||
aggCmdObj.pipeline[0]["$_analyzeShardKeyReadWriteDistribution"].splitPointsNss);
|
||||
assert.commandWorked(splitPointsColl.insert({splitPoint: {_id: 1}}));
|
||||
assert.commandWorked(splitPointsColl.insert({_id: UUID(), splitPoint: {_id: 1}}));
|
||||
assert.commandFailedWithCode(
|
||||
shard0Primary.getDB(validationTest.dbName).runCommand(aggCmdObj), ErrorCodes.BadValue);
|
||||
splitPointsColl.drop();
|
||||
|
@ -635,7 +635,18 @@ std::pair<NamespaceString, Timestamp> generateSplitPoints(OperationContext* opCt
|
||||
uasserted(ErrorCodes::FailedToParse, errMsg);
|
||||
}
|
||||
|
||||
uassertStatusOK(res.toStatus());
|
||||
if (res.isErrDetailsSet() && res.sizeErrDetails() > 0) {
|
||||
for (const auto& err : res.getErrDetails()) {
|
||||
if (err.getStatus() == ErrorCodes::DuplicateKey) {
|
||||
LOGV2(7433800, "Ignoring insert error", "error"_attr = redact(err.getStatus()));
|
||||
continue;
|
||||
}
|
||||
uassertStatusOK(err.getStatus());
|
||||
}
|
||||
} else {
|
||||
uassertStatusOK(res.toStatus());
|
||||
}
|
||||
|
||||
splitPointsAfterClusterTime = LogicalTime::fromOperationTime(resObj).asTimestamp();
|
||||
};
|
||||
|
||||
@ -653,6 +664,7 @@ std::pair<NamespaceString, Timestamp> generateSplitPoints(OperationContext* opCt
|
||||
splitPointsToInsert.clear();
|
||||
}
|
||||
AnalyzeShardKeySplitPointDocument doc;
|
||||
doc.setId(UUID::gen());
|
||||
doc.setSplitPoint(splitPoint);
|
||||
splitPointsToInsert.push_back(doc.toBSON());
|
||||
objSize += splitPoint.objsize();
|
||||
|
@ -110,5 +110,9 @@ structs:
|
||||
analyzeShardKey command."
|
||||
strict: false
|
||||
fields:
|
||||
_id:
|
||||
type: uuid
|
||||
description: "The unique id for the split point."
|
||||
cpp_name: id
|
||||
splitPoint:
|
||||
type: object
|
||||
|
Loading…
Reference in New Issue
Block a user