blob: 0b444c713ae30a1ab29807c4c9910ea9b0e50ae0 (
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
50
51
52
53
54
55
56
57
58
59
|
/**
* Tests that when directoryperdb is enabled, newly empty database directories are removed for
* replicated collection with two-phase drops.
*
* @tags: [
* requires_fcv_48,
* requires_majority_read_concern,
* requires_persistence,
* ]
*/
(function() {
"use strict";
const dbToDropName = jsTestName() + "_drop";
const dbToKeepName = jsTestName() + "_keep";
const rst = new ReplSetTest({
nodes: 1,
nodeOptions: {directoryperdb: "", setParameter: {minSnapshotHistoryWindowInSeconds: 0}}
});
rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
const dbToDrop = primary.getDB(dbToDropName);
const dbToKeep = primary.getDB(dbToKeepName);
const collToKeep = dbToKeep.getCollection(jsTestName());
const runTest = function(dropDatabase) {
assert.commandWorked(primary.adminCommand({clearLog: "global"}));
const collToDrop = dbToDrop.getCollection(jsTestName() + "_1");
assert.commandWorked(collToDrop.insert({a: 1}));
if (dropDatabase) {
assert.commandWorked(dbToDrop.dropDatabase());
} else {
assert(collToDrop.drop());
}
// Move the oldest_timestamp forward past the drop timestamp and take a checkpoint so that the
// second phase of the collection drop can occur.
assert.commandWorked(collToKeep.insert({}));
rst.awaitLastOpCommitted();
assert.commandWorked(primary.adminCommand({fsync: 1}));
// Ensure that the empty database directory was removed.
checkLog.containsJson(primary, 4888200, {db: dbToDropName});
const files = listFiles(rst.getDbPath(primary));
assert(!files.some(file => file.baseName === dbToDropName),
"Database directory " + dbToDropName +
" found even though it should have been removed: " + tojson(files));
};
runTest(false);
runTest(true);
rst.stopSet();
})();
|