mirror of https://github.com/mongodb/mongo
SERVER-100721 Make sure that 'skipCloningAndApplying' and 'storeOplogFetcherProgress' in resharding recipient state doc are only set when feature flags are enabled (#32260)
GitOrigin-RevId: d4db9f5f0bce0ff0b074843eafa08b82cd0b8cc8
This commit is contained in:
parent
722d82bb12
commit
cca935c5d3
|
|
@ -93,8 +93,7 @@ structs:
|
||||||
optional: true
|
optional: true
|
||||||
description: "The timestamp for the snapshot read while cloning from the donors."
|
description: "The timestamp for the snapshot read while cloning from the donors."
|
||||||
skipCloningAndApplying:
|
skipCloningAndApplying:
|
||||||
type: bool
|
type: optionalBool
|
||||||
optional: true
|
|
||||||
description: "Whether this recipient can skip cloning documents and
|
description: "Whether this recipient can skip cloning documents and
|
||||||
fetching/applying oplog entries because it is not going to own any
|
fetching/applying oplog entries because it is not going to own any
|
||||||
chunks for the collection after resharding."
|
chunks for the collection after resharding."
|
||||||
|
|
|
||||||
|
|
@ -374,15 +374,16 @@ ReshardingRecipientDocument constructRecipientDocumentFromReshardingFields(
|
||||||
recipientDoc.setMetrics(std::move(metrics));
|
recipientDoc.setMetrics(std::move(metrics));
|
||||||
|
|
||||||
recipientDoc.setCommonReshardingMetadata(std::move(commonMetadata));
|
recipientDoc.setCommonReshardingMetadata(std::move(commonMetadata));
|
||||||
const bool skipCloningAndApplying =
|
|
||||||
resharding::gFeatureFlagReshardingSkipCloningAndApplyingIfApplicable.isEnabled(
|
|
||||||
serverGlobalParams.featureCompatibility.acquireFCVSnapshot()) &&
|
|
||||||
!metadata.currentShardHasAnyChunks();
|
|
||||||
recipientDoc.setSkipCloningAndApplying(skipCloningAndApplying);
|
|
||||||
|
|
||||||
recipientDoc.setStoreOplogFetcherProgress(
|
if (resharding::gFeatureFlagReshardingSkipCloningAndApplyingIfApplicable.isEnabled(
|
||||||
resharding::gFeatureFlagReshardingStoreOplogFetcherProgress.isEnabled(
|
serverGlobalParams.featureCompatibility.acquireFCVSnapshot()) &&
|
||||||
serverGlobalParams.featureCompatibility.acquireFCVSnapshot()));
|
!metadata.currentShardHasAnyChunks()) {
|
||||||
|
recipientDoc.setSkipCloningAndApplying(true);
|
||||||
|
}
|
||||||
|
if (resharding::gFeatureFlagReshardingStoreOplogFetcherProgress.isEnabled(
|
||||||
|
serverGlobalParams.featureCompatibility.acquireFCVSnapshot())) {
|
||||||
|
recipientDoc.setStoreOplogFetcherProgress(true);
|
||||||
|
}
|
||||||
|
|
||||||
recipientDoc.setOplogBatchTaskCount(recipientFields->getOplogBatchTaskCount());
|
recipientDoc.setOplogBatchTaskCount(recipientFields->getOplogBatchTaskCount());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -354,8 +354,12 @@ private:
|
||||||
|
|
||||||
struct DonorFieldsValidator {
|
struct DonorFieldsValidator {
|
||||||
void validate(ReshardingDonorDocument doc) {
|
void validate(ReshardingDonorDocument doc) {
|
||||||
|
// 'performVerification' should only be set if it is specified.
|
||||||
if (performVerification) {
|
if (performVerification) {
|
||||||
ASSERT_EQ(doc.getPerformVerification(), *performVerification);
|
ASSERT_EQ(doc.getPerformVerification(), *performVerification);
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(doc.getPerformVerification().has_value());
|
||||||
|
ASSERT_EQ(doc.getPerformVerification(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -364,19 +368,31 @@ struct DonorFieldsValidator {
|
||||||
|
|
||||||
struct RecipientFieldsValidator {
|
struct RecipientFieldsValidator {
|
||||||
void validate(ReshardingRecipientDocument doc) {
|
void validate(ReshardingRecipientDocument doc) {
|
||||||
|
// 'skipCloningAndApplying' should only be set if it is true.
|
||||||
if (skipCloningAndApplying) {
|
if (skipCloningAndApplying) {
|
||||||
ASSERT_EQ(doc.getSkipCloningAndApplying(), *skipCloningAndApplying);
|
ASSERT_EQ(doc.getSkipCloningAndApplying(), skipCloningAndApplying);
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(doc.getSkipCloningAndApplying().has_value());
|
||||||
|
ASSERT_EQ(doc.getSkipCloningAndApplying(), false);
|
||||||
}
|
}
|
||||||
|
// 'storeOplogFetcherProgress' should only be set if it is true.
|
||||||
if (storeOplogFetcherProgress) {
|
if (storeOplogFetcherProgress) {
|
||||||
ASSERT_EQ(doc.getStoreOplogFetcherProgress(), *storeOplogFetcherProgress);
|
ASSERT_EQ(doc.getStoreOplogFetcherProgress(), storeOplogFetcherProgress);
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(doc.getStoreOplogFetcherProgress().has_value());
|
||||||
|
ASSERT_EQ(doc.getStoreOplogFetcherProgress(), false);
|
||||||
}
|
}
|
||||||
|
// 'performVerification' should only be set if it is specified.
|
||||||
if (performVerification) {
|
if (performVerification) {
|
||||||
ASSERT_EQ(doc.getPerformVerification(), *performVerification);
|
ASSERT_EQ(doc.getPerformVerification(), *performVerification);
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(doc.getPerformVerification().has_value());
|
||||||
|
ASSERT_EQ(doc.getPerformVerification(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<bool> skipCloningAndApplying;
|
bool skipCloningAndApplying;
|
||||||
boost::optional<bool> storeOplogFetcherProgress;
|
bool storeOplogFetcherProgress;
|
||||||
boost::optional<bool> performVerification;
|
boost::optional<bool> performVerification;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -834,17 +850,35 @@ TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
false /* expectDonorStateMachine */);
|
false /* expectDonorStateMachine */);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReshardingDonorRecipientCommonTest, ProcessDonorFieldsPerformVerificationUnspecified) {
|
TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
|
ProcessDonorFieldsPerformVerificationUnspecified_FeatureFlagEnabled) {
|
||||||
|
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
||||||
|
"featureFlagReshardingVerification", true);
|
||||||
auto performVerification = boost::none;
|
auto performVerification = boost::none;
|
||||||
|
|
||||||
testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
kOtherShard.getShardId() /* primaryShard */,
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
performVerification,
|
performVerification,
|
||||||
true /* expectDonorStateMachine */,
|
true /* expectDonorStateMachine */,
|
||||||
DonorFieldsValidator{.performVerification = false});
|
DonorFieldsValidator{});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
|
ProcessDonorFieldsPerformVerificationUnspecified_FeatureFlagDisabled) {
|
||||||
|
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
||||||
|
"featureFlagReshardingVerification", false);
|
||||||
|
auto performVerification = boost::none;
|
||||||
|
|
||||||
|
testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
|
performVerification,
|
||||||
|
true /* expectDonorStateMachine */,
|
||||||
|
DonorFieldsValidator{});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReshardingDonorRecipientCommonTest, ProcessDonorFieldsNotPerformVerification) {
|
TEST_F(ReshardingDonorRecipientCommonTest, ProcessDonorFieldsNotPerformVerification) {
|
||||||
bool performVerification = false;
|
bool performVerification = false;
|
||||||
|
|
||||||
testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
kOtherShard.getShardId() /* primaryShard */,
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
performVerification,
|
performVerification,
|
||||||
|
|
@ -856,8 +890,8 @@ TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
ProcessDonorFieldsPerformVerification_FeatureFlagEnabled) {
|
ProcessDonorFieldsPerformVerification_FeatureFlagEnabled) {
|
||||||
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
||||||
"featureFlagReshardingVerification", true);
|
"featureFlagReshardingVerification", true);
|
||||||
|
|
||||||
bool performVerification = true;
|
bool performVerification = true;
|
||||||
|
|
||||||
testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
kOtherShard.getShardId() /* primaryShard */,
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
performVerification,
|
performVerification,
|
||||||
|
|
@ -869,8 +903,8 @@ TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
ProcessDonorFieldsPerformVerification_FeatureFlagDisabled) {
|
ProcessDonorFieldsPerformVerification_FeatureFlagDisabled) {
|
||||||
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
||||||
"featureFlagReshardingVerification", false);
|
"featureFlagReshardingVerification", false);
|
||||||
|
|
||||||
bool performVerification = true;
|
bool performVerification = true;
|
||||||
|
|
||||||
ASSERT_THROWS_CODE(testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
ASSERT_THROWS_CODE(testProcessDonorFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
kOtherShard.getShardId() /* primaryShard */,
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
performVerification,
|
performVerification,
|
||||||
|
|
@ -935,17 +969,35 @@ TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
RecipientFieldsValidator{.skipCloningAndApplying = false});
|
RecipientFieldsValidator{.skipCloningAndApplying = false});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReshardingDonorRecipientCommonTest, ProcessRecipientFieldsPerformVerificationUnspecified) {
|
TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
auto performVerification = boost::none;
|
ProcessRecipientFieldsPerformVerificationUnspecified_FeatureFlagEnabled) {
|
||||||
|
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
||||||
|
"featureFlagReshardingVerification", true);
|
||||||
|
boost::optional<bool> performVerification = boost::none;
|
||||||
|
|
||||||
testProcessRecipientFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
testProcessRecipientFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
kOtherShard.getShardId() /* primaryShard */,
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
performVerification,
|
performVerification,
|
||||||
true /* expectRecipientStateMachine */,
|
true /* expectRecipientStateMachine */,
|
||||||
RecipientFieldsValidator{.performVerification = false});
|
RecipientFieldsValidator{});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ReshardingDonorRecipientCommonTest,
|
||||||
|
ProcessRecipientFieldsPerformVerificationUnspecified_FeatureFlagDisabled) {
|
||||||
|
RAIIServerParameterControllerForTest verificationFeatureFlagController(
|
||||||
|
"featureFlagReshardingVerification", false);
|
||||||
|
auto performVerification = boost::none;
|
||||||
|
|
||||||
|
testProcessRecipientFields(kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
|
performVerification,
|
||||||
|
true /* expectRecipientStateMachine */,
|
||||||
|
RecipientFieldsValidator{});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReshardingDonorRecipientCommonTest, ProcessRecipientFieldsNotPerformVerification) {
|
TEST_F(ReshardingDonorRecipientCommonTest, ProcessRecipientFieldsNotPerformVerification) {
|
||||||
bool performVerification = false;
|
bool performVerification = false;
|
||||||
|
|
||||||
testProcessRecipientFields(
|
testProcessRecipientFields(
|
||||||
kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
kThisShard.getShardId() /* shardThatChunkExistsOn*/,
|
||||||
kOtherShard.getShardId() /* primaryShard */,
|
kOtherShard.getShardId() /* primaryShard */,
|
||||||
|
|
|
||||||
|
|
@ -554,7 +554,7 @@ void validatePerformVerification(boost::optional<bool> performVerification) {
|
||||||
|
|
||||||
void validatePerformVerification(bool performVerification) {
|
void validatePerformVerification(bool performVerification) {
|
||||||
uassert(ErrorCodes::InvalidOptions,
|
uassert(ErrorCodes::InvalidOptions,
|
||||||
str::stream() << "Cannot specify '"
|
str::stream() << "Cannot set '"
|
||||||
<< CommonReshardingMetadata::kPerformVerificationFieldName
|
<< CommonReshardingMetadata::kPerformVerificationFieldName
|
||||||
<< "' to true when featureFlagReshardingVerification is not enabled",
|
<< "' to true when featureFlagReshardingVerification is not enabled",
|
||||||
!performVerification ||
|
!performVerification ||
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue