mirror of https://github.com/mongodb/mongo
SERVER-25916: disable doc validation for all writes during bulk collection cloning in initial sync.
This commit is contained in:
parent
f2c3376d70
commit
b3aba5d4d1
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Tests that initial sync via resync command does not fail if it inserts documents
|
||||
* which don't validate.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var name = 'initial_sync_document_validation';
|
||||
var replSet = new ReplSetTest({
|
||||
name: name,
|
||||
nodes: 2,
|
||||
});
|
||||
|
||||
replSet.startSet();
|
||||
replSet.initiate();
|
||||
var primary = replSet.getPrimary();
|
||||
var secondary = replSet.getSecondary();
|
||||
|
||||
var coll = primary.getDB('test').getCollection(name);
|
||||
assert.writeOK(coll.insert({_id: 0, x: 1}));
|
||||
assert.commandWorked(coll.runCommand("collMod", {"validator": {a: {$exists: true}}}));
|
||||
|
||||
assert.commandWorked(secondary.getDB("admin").runCommand({resync: 1}));
|
||||
replSet.awaitReplication();
|
||||
replSet.awaitSecondaryNodes();
|
||||
|
||||
assert.eq(1, secondary.getDB("test")[name].count());
|
||||
assert.docEq({_id: 0, x: 1}, secondary.getDB("test")[name].findOne());
|
||||
|
||||
replSet.stopSet();
|
||||
})();
|
||||
|
|
@ -253,9 +253,10 @@ StorageInterfaceImpl::createCollectionForBulkLoading(
|
|||
std::unique_ptr<CollectionBulkLoader> loaderToReturn;
|
||||
|
||||
auto status = runner->runSynchronousTask([&](OperationContext* txn) -> Status {
|
||||
// We are not replicating nor validating these writes.
|
||||
// We are not replicating nor validating writes under this OperationContext*.
|
||||
// The OperationContext* is used for all writes to the (newly) cloned collection.
|
||||
txn->setReplicatedWrites(false);
|
||||
DisableDocumentValidation validationDisabler(txn);
|
||||
documentValidationDisabled(txn) = true;
|
||||
|
||||
// Retry if WCE.
|
||||
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
|
||||
|
|
|
|||
Loading…
Reference in New Issue