2017-07-12 09:52:02 -04:00
|
|
|
// Validates cases where index scans are aborted due to the collection being dropped (SERVER-4400)
|
2017-10-20 16:11:32 -04:00
|
|
|
//
|
|
|
|
|
// Drop and other sharding commands can conflict with LockBusy errors in a sharding passthrough
|
|
|
|
|
// suite. This is because drop against a mongos takes distlocks, whereas drop against a mongod does
|
|
|
|
|
// not. Due to the huge number of parallel drops in this test, the other thead is very likely to be
|
|
|
|
|
// starved frequently.
|
|
|
|
|
// Note: this tag can be safely removed once PM-697 is complete and replaces distlocks with a
|
|
|
|
|
// LockManager that has a fairness policy, which distlocks lack.
|
2019-03-11 18:17:29 -04:00
|
|
|
// @tags: [
|
|
|
|
|
// assumes_against_mongod_not_mongos,
|
|
|
|
|
// requires_non_retryable_writes,
|
|
|
|
|
// uses_multiple_connections,
|
|
|
|
|
// ]
|
2017-10-20 16:11:32 -04:00
|
|
|
|
2017-07-12 09:52:02 -04:00
|
|
|
(function() {
|
2019-07-26 18:20:35 -04:00
|
|
|
'use strict';
|
2011-11-30 22:20:07 -08:00
|
|
|
|
2019-07-26 18:20:35 -04:00
|
|
|
var coll = db.jstests_queryoptimizer3;
|
2011-11-30 22:20:07 -08:00
|
|
|
|
2019-07-26 18:20:35 -04:00
|
|
|
var shellWaitHandle = startParallelShell(function() {
|
|
|
|
|
for (var i = 0; i < 400; ++i) {
|
|
|
|
|
sleep(50);
|
|
|
|
|
try {
|
|
|
|
|
db.jstests_queryoptimizer3.drop();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (e.code === ErrorCodes.BackgroundOperationInProgressForNamespace) {
|
|
|
|
|
print("Background operation temporarily in progress while attempting to drop " +
|
|
|
|
|
"collection.");
|
|
|
|
|
continue;
|
2019-01-02 16:48:56 -05:00
|
|
|
}
|
2019-07-26 18:20:35 -04:00
|
|
|
throw e;
|
2017-07-12 09:52:02 -04:00
|
|
|
}
|
2019-07-26 18:20:35 -04:00
|
|
|
}
|
|
|
|
|
});
|
2011-11-30 22:20:07 -08:00
|
|
|
|
2019-07-26 18:20:35 -04:00
|
|
|
for (var i = 0; i < 100; ++i) {
|
|
|
|
|
coll.drop();
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: 1}));
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({b: 1}));
|
2017-07-12 09:52:02 -04:00
|
|
|
|
2019-07-26 18:20:35 -04:00
|
|
|
var bulk = coll.initializeUnorderedBulkOp();
|
|
|
|
|
for (var j = 0; j < 100; ++j) {
|
|
|
|
|
bulk.insert({a: j, b: j});
|
|
|
|
|
}
|
|
|
|
|
assert.commandWorked(bulk.execute());
|
2014-10-21 10:24:24 -04:00
|
|
|
|
2019-07-26 18:20:35 -04:00
|
|
|
try {
|
|
|
|
|
var m = i % 5;
|
|
|
|
|
if (m == 0) {
|
|
|
|
|
coll.count({a: {$gte: 0}, b: {$gte: 0}});
|
|
|
|
|
} else if (m == 1) {
|
|
|
|
|
coll.find({a: {$gte: 0}, b: {$gte: 0}}).itcount();
|
|
|
|
|
} else if (m == 2) {
|
|
|
|
|
coll.remove({a: {$gte: 0}, b: {$gte: 0}});
|
|
|
|
|
} else if (m == 3) {
|
|
|
|
|
coll.update({a: {$gte: 0}, b: {$gte: 0}}, {});
|
|
|
|
|
} else if (m == 4) {
|
|
|
|
|
coll.distinct('x', {a: {$gte: 0}, b: {$gte: 0}});
|
2014-10-21 10:24:24 -04:00
|
|
|
}
|
2019-07-26 18:20:35 -04:00
|
|
|
} catch (e) {
|
|
|
|
|
print("Op killed during yield: " + e.message);
|
2011-11-30 22:20:07 -08:00
|
|
|
}
|
2019-07-26 18:20:35 -04:00
|
|
|
}
|
2011-11-30 22:20:07 -08:00
|
|
|
|
2019-07-26 18:20:35 -04:00
|
|
|
shellWaitHandle();
|
2014-10-21 10:24:24 -04:00
|
|
|
|
2019-07-26 18:20:35 -04:00
|
|
|
// Ensure that the server is still responding
|
|
|
|
|
assert.commandWorked(db.runCommand({isMaster: 1}));
|
2017-07-12 09:52:02 -04:00
|
|
|
})();
|