summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/compact_stops_on_ebusy.js
blob: dccc2ce3624107acf70d2bfb8d17cd07a0299d5a (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
/**
 * Checks that the compact command exits cleanly on EBUSY.
 *
 * @tags: [requires_wiredtiger, requires_persistence]
 */
(function() {
"use strict";

const conn = MongoRunner.runMongod({});
const db = conn.getDB("test");
const coll = db.getCollection(jsTest.name());

for (let i = 0; i < 10; i++) {
    assert.commandWorked(coll.insert({x: i}));
}

const failPoints = ["WTCompactRecordStoreEBUSY", "WTCompactIndexEBUSY"];
for (const failPoint of failPoints) {
    assert.commandWorked(db.adminCommand({configureFailPoint: failPoint, mode: "alwaysOn"}));
    assert.commandFailedWithCode(db.runCommand({compact: jsTest.name()}), ErrorCodes.Interrupted);
    assert.commandWorked(db.adminCommand({configureFailPoint: failPoint, mode: "off"}));
}

MongoRunner.stopMongod(conn);
}());