blob: 42fad3c07b3aa6174063cfc09bbacc7490f447c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// SERVER-16676 Make sure compact doesn't leave the collection with bad indexes
// SERVER-16967 Make sure compact doesn't crash while collections are being dropped
// in a different database.
// The test runs commands that are not allowed with security token: compact.
// @tags: [
// not_allowed_with_security_token,
// # compact command is not available on embedded
// incompatible_with_embedded,
// uses_multiple_connections,
// uses_parallel_shell,
// uses_compact,
// ]
(function() {
'use strict';
var coll = db.compact_keeps_indexes;
coll.drop();
coll.insert({_id: 1, x: 1});
coll.createIndex({x: 1});
assert.eq(coll.getIndexes().length, 2);
// force:true is for replset passthroughs
var res = coll.runCommand('compact', {force: true});
// Some storage engines (for example, inMemoryExperiment) do not support the compact command.
if (res.code == 115) { // CommandNotSupported
return;
}
assert.commandWorked(res);
assert.eq(coll.getIndexes().length, 2);
assert.eq(coll.find({_id: 1}).itcount(), 1);
assert.eq(coll.find({x: 1}).itcount(), 1);
var dropCollectionShell = startParallelShell(function() {
var t = db.getSiblingDB('test_compact_keeps_indexes_drop').testcoll;
t.drop();
for (var i = 0; i < 100; i++) {
t.save({a: 1});
t.drop();
}
});
for (var i = 0; i < 10; i++) {
coll.runCommand('compact');
}
dropCollectionShell();
}());
|