SERVER-120901 Disallow repair for modal validation (#50499)
GitOrigin-RevId: 860cc8ef6ba7700a4acd8a47279d1da630d1c679
This commit is contained in:
parent
080a88d4b4
commit
d3a4297d78
@ -63,7 +63,7 @@ function runDbTest() {
|
||||
assert.eq(2, secondResult.nIndexes);
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
// Error if collection is non-existant
|
||||
// Error if collection is non-existent
|
||||
assert.neq(
|
||||
MongoRunner.EXIT_CLEAN,
|
||||
runMongoProgram(
|
||||
@ -79,6 +79,80 @@ function runDbTest() {
|
||||
"validateCollectionName=lettuce",
|
||||
),
|
||||
);
|
||||
|
||||
// Validate can be run with repair:false but not repair:true when running modal validation.
|
||||
assert.eq(
|
||||
MongoRunner.EXIT_CLEAN,
|
||||
runMongoProgram(
|
||||
"mongod",
|
||||
"--validate",
|
||||
"--port",
|
||||
port,
|
||||
"--dbpath",
|
||||
dbpath,
|
||||
"--setParameter",
|
||||
"validateDbName=test",
|
||||
"--setParameter",
|
||||
"validateCollectionName=ham",
|
||||
"--setParameter",
|
||||
`collectionValidateOptions={options: {repair: false}}`,
|
||||
),
|
||||
);
|
||||
|
||||
assert.neq(
|
||||
MongoRunner.EXIT_CLEAN,
|
||||
runMongoProgram(
|
||||
"mongod",
|
||||
"--validate",
|
||||
"--port",
|
||||
port,
|
||||
"--dbpath",
|
||||
dbpath,
|
||||
"--setParameter",
|
||||
"validateDbName=test",
|
||||
"--setParameter",
|
||||
"validateCollectionName=ham",
|
||||
"--setParameter",
|
||||
`collectionValidateOptions={options: {repair: true}}`,
|
||||
),
|
||||
);
|
||||
|
||||
// The same as above, but for fixMultikey.
|
||||
assert.eq(
|
||||
MongoRunner.EXIT_CLEAN,
|
||||
runMongoProgram(
|
||||
"mongod",
|
||||
"--validate",
|
||||
"--port",
|
||||
port,
|
||||
"--dbpath",
|
||||
dbpath,
|
||||
"--setParameter",
|
||||
"validateDbName=test",
|
||||
"--setParameter",
|
||||
"validateCollectionName=ham",
|
||||
"--setParameter",
|
||||
`collectionValidateOptions={options: {fixMultikey: false}}`,
|
||||
),
|
||||
);
|
||||
|
||||
assert.neq(
|
||||
MongoRunner.EXIT_CLEAN,
|
||||
runMongoProgram(
|
||||
"mongod",
|
||||
"--validate",
|
||||
"--port",
|
||||
port,
|
||||
"--dbpath",
|
||||
dbpath,
|
||||
"--setParameter",
|
||||
"validateDbName=test",
|
||||
"--setParameter",
|
||||
"validateCollectionName=ham",
|
||||
"--setParameter",
|
||||
`collectionValidateOptions={options: {fixMultikey: true}}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
runDbTest();
|
||||
|
||||
@ -762,6 +762,10 @@ StatusWith<bool> offlineValidateCollection(OperationContext* opCtx,
|
||||
CollectionValidation::ValidateMode::kForegroundFull,
|
||||
CollectionValidation::RepairMode::kNone,
|
||||
/*logDiagnostics=*/false);
|
||||
if (parsedOptions.getRepairMode() != CollectionValidation::RepairMode::kNone) {
|
||||
return Status{ErrorCodes::InvalidOptions,
|
||||
"Repair is not allowed in offline validation mode"};
|
||||
}
|
||||
ValidateResults validateResults;
|
||||
try {
|
||||
Status status = CollectionValidation::validate(opCtx, nss, parsedOptions, &validateResults);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user