2016-09-02 15:39:06 +02:00
|
|
|
/**
|
|
|
|
* Tests that initial sync can complete after a failed insert to a cloned collection.
|
2016-09-20 23:27:32 +02:00
|
|
|
* The failpoint may fail once or twice depending on the order of the results of listCollection,
|
|
|
|
* so we allow initial sync to retry 3 times.
|
2016-09-02 15:39:06 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
2019-07-27 00:20:35 +02:00
|
|
|
var name = 'initial_sync_fail_insert_once';
|
|
|
|
var replSet = new ReplSetTest(
|
|
|
|
{name: name, nodes: 2, nodeOptions: {setParameter: "numInitialSyncAttempts=3"}});
|
2016-09-02 15:39:06 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
replSet.startSet();
|
|
|
|
replSet.initiate();
|
|
|
|
var primary = replSet.getPrimary();
|
|
|
|
var secondary = replSet.getSecondary();
|
2016-09-02 15:39:06 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var coll = primary.getDB('test').getCollection(name);
|
2019-08-14 15:52:59 +02:00
|
|
|
assert.commandWorked(coll.insert({_id: 0, x: 1}, {writeConcern: {w: 2}}));
|
2016-09-02 15:39:06 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
jsTest.log("Re-syncing " + tojson(secondary));
|
2019-12-20 20:44:43 +01:00
|
|
|
const params = {
|
|
|
|
'failpoint.failCollectionInserts':
|
|
|
|
tojson({mode: {times: 2}, data: {collectionNS: coll.getFullName()}})
|
|
|
|
};
|
|
|
|
|
|
|
|
secondary = replSet.restart(secondary, {startClean: true, setParameter: params});
|
2019-07-27 00:20:35 +02:00
|
|
|
replSet.awaitReplication();
|
|
|
|
replSet.awaitSecondaryNodes();
|
2016-09-02 15:39:06 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
assert.eq(1, secondary.getDB("test")[name].count());
|
|
|
|
assert.docEq({_id: 0, x: 1}, secondary.getDB("test")[name].findOne());
|
2016-09-02 15:39:06 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
jsTest.log("Stopping repl set test; finished.");
|
|
|
|
replSet.stopSet();
|
2016-09-02 15:39:06 +02:00
|
|
|
})();
|