var mongo = MongoRunner.runMongod();
|
var testDB = mongo.getDB('interrupts');
|
|
testDB.dropDatabase();
|
var coll = testDB.aggInterrupt;
|
|
// insert dummy data
|
var bigStr = Array(1024*1024 + 1).toString(); // 1MB of ','
|
for (var i = 0; i < 1000; i++) {
|
coll.insert({_id: i, bigStr: String(i) + bigStr, random: Math.random()});
|
}
|
|
// set up failpoint
|
var conn = testDB.currentOp(true).inprog.filter(function(element){return element.connectionId;})[0].connectionId;
|
testDB.getSiblingDB('admin').runCommand({configureFailPoint: 'checkForInterruptFail', mode: 'alwaysOn', data: {chance: 0.05, conn: conn, allowNested: true}});
|
|
// loop until the drop of a temp table is interrupted
|
for (var i = 0; i < 1000; i++) {
|
print(i);
|
|
try {
|
var pipeline = [{$sort: {random:1}}, {$group: {_id: '$_id', bigStr: {$first: '$bigStr'}}} , {$out: 'outputColl'}];
|
coll.aggregate(pipeline, {allowDiskUsage: true});
|
} catch (e) {
|
print(e);
|
}
|
|
var res = {};
|
do {
|
try {
|
print('attempting to drop output collection');
|
res = testDB.outputColl.drop();
|
} catch (e) {
|
print('failed to drop output collection -- retrying');
|
res.ok = 0;
|
}
|
} while(res.ok === 0);
|
|
var names;
|
do {
|
try {
|
print('attempting to get collection names');
|
names = testDB.getCollectionNames();
|
} catch (e) {
|
print('failed to get collection names -- retrying');
|
names = [];
|
}
|
} while(names.length === 0);
|
|
assert.eq(names, ['aggInterrupt', 'system.indexes']);
|
}
|