summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/database_differ_case.js
blob: bf2a76e9d248162f4f6478ee62700ab1c4bf76d1 (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
/**
 * Ensures that replicating the dropDatabase oplog entry and clearing the collection catalog during
 * dropDatabase is done atomically. This prevents a problem where we step down after writing out the
 * dropDatabase oplog entry, the node becomes a secondary with the collection catalog still
 * containing the database name. If the new primary creates the same database name with a different
 * casing, the secondary would fatally assert.
 */
(function() {
"use strict";

load("jstests/libs/fail_point_util.js");

const rst = new ReplSetTest({nodes: 3});
rst.startSet();
rst.initiateWithHighElectionTimeout();

let primary = rst.getPrimary();

assert.commandWorked(primary.getDB("test").createCollection("a"));

let awaitDrop = startParallelShell(() => {
    db.getSiblingDB("test").dropDatabase();
}, primary.port);
let awaitFailPoint = configureFailPoint(primary, "dropDatabaseHangBeforeInMemoryDrop");
awaitFailPoint.wait();

// Wait for secondaries to apply the dropDatabase oplog entry.
rst.awaitReplication();

// Make the primary step down before finishing dropDatabase.
assert.commandWorked(primary.getDB("admin").adminCommand({replSetStepDown: 30}));

awaitFailPoint.off();
awaitDrop();

assert.commandFailedWithCode(rst.getPrimary().getDB("TEST").createCollection("a"),
                             ErrorCodes.DatabaseDifferCase);
rst.stopSet();
})();