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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/**
* Tests that MongoDB gives errors when certain data files are missing.
*
* @tags: [requires_wiredtiger]
*/
(function() {
load('jstests/disk/libs/wt_file_helper.js');
const baseName = "wt_missing_file_errors";
const collName = "test";
const dbpath = MongoRunner.dataPath + baseName + "/";
/**
* Test 1. Delete a collection's .wt file.
*/
assertErrorOnRequestWhenFilesAreCorruptOrMissing(
dbpath,
baseName,
collName,
(mongod, testColl) => {
const testCollUri = getUriForColl(testColl);
const testCollFile = dbpath + testCollUri + ".wt";
MongoRunner.stopMongod(mongod);
jsTestLog("deleting collection file: " + testCollFile);
removeFile(testCollFile);
},
(testColl) => {
assert.throws(() => {
testColl.insert({a: 1});
});
},
"Fatal Assertion 50883");
/**
* Test 2. Delete the _mdb_catalog.
*/
assertErrorOnStartupWhenFilesAreCorruptOrMissing(dbpath, baseName, collName, (mongod, testColl) => {
MongoRunner.stopMongod(mongod);
let mdbCatalogFile = dbpath + "_mdb_catalog.wt";
jsTestLog("deleting catalog file: " + mdbCatalogFile);
removeFile(mdbCatalogFile);
}, "Fatal Assertion 50883");
/**
* Test 3. Delete the WiredTiger.wt.
*/
assertErrorOnStartupWhenFilesAreCorruptOrMissing(dbpath, baseName, collName, (mongod, testColl) => {
MongoRunner.stopMongod(mongod);
let WiredTigerWTFile = dbpath + "WiredTiger.wt";
jsTestLog("deleting WiredTiger.wt");
removeFile(WiredTigerWTFile);
}, "Fatal Assertion 28595");
/**
* Test 4. Delete an index file.
*/
assertErrorOnRequestWhenFilesAreCorruptOrMissing(
dbpath,
baseName,
collName,
(mongod, testColl) => {
const indexName = "a_1";
assert.commandWorked(testColl.createIndex({a: 1}, {name: indexName}));
const indexUri = getUriForIndex(testColl, indexName);
MongoRunner.stopMongod(mongod);
const indexFile = dbpath + indexUri + ".wt";
jsTestLog("deleting index file: " + indexFile);
removeFile(indexFile);
},
(testColl) => {
// This insert will crash the server because it triggers the code path
// of looking for the index file.
assert.throws(function() {
testColl.insert({a: 1});
});
},
"Fatal Assertion 50883");
})();
|