blob: 6515cbef8f7d052c97d7b26aeec8bb1ebdb64b60 (
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
|
/**
* Tests that the server will startup normally when a collection has a missing id index.
*
* @tags: [requires_persistence]
*/
(function() {
"use strict";
load("jstests/libs/index_catalog_helpers.js");
load("jstests/libs/fail_point_util.js");
let conn = MongoRunner.runMongod();
const dbName = jsTestName();
const collName = "coll";
let testDB = conn.getDB(dbName);
let coll = testDB.getCollection(collName);
assert.commandWorked(testDB.adminCommand({configureFailPoint: "skipIdIndex", mode: "alwaysOn"}));
assert.commandWorked(testDB.createCollection(collName));
for (let i = 0; i < 1500; ++i) {
assert.commandWorked(coll.insert({_id: i, a: 1}));
}
let indexSpec = IndexCatalogHelpers.findByName(coll.getIndexes(), "_id_");
assert.eq(indexSpec, null);
MongoRunner.stopMongod(conn);
// We should be able to successfully restart the server even though 'coll' is missing an id index.
conn = MongoRunner.runMongod({dbpath: conn.dbpath, noCleanData: true});
assert(conn);
// Check for the log message where we build missing id indexes in startup recovery.
checkLog.containsJson(conn, 4805002);
testDB = conn.getDB(dbName);
coll = testDB.getCollection(collName);
indexSpec = IndexCatalogHelpers.findByName(coll.getIndexes(), "_id_");
assert.neq(indexSpec, null);
MongoRunner.stopMongod(conn);
})();
|