|
| 1 | +/** |
| 2 | + * Tests server behavior when a StorageUnavailableException is thrown when a PlanExecutor is being |
| 3 | + * restored. Specifically, tests the case where the exception is thrown when the getMore command |
| 4 | + * is restoring the cursor in order to use it, as well as a case where the BatchedDeleteStage |
| 5 | + * throws when restoring. |
| 6 | + */ |
| 7 | + |
| 8 | +const conn = MongoRunner.runMongod(); |
| 9 | +assert.neq(null, conn, "mongod was unable to start up"); |
| 10 | + |
| 11 | +const db = conn.getDB("test"); |
| 12 | + |
| 13 | +function runTest() { |
| 14 | + load("jstests/libs/fail_point_util.js"); |
| 15 | + |
| 16 | + let collName = jsTestName(); |
| 17 | + db[collName].drop(); |
| 18 | + |
| 19 | + for (let x = 0; x < 5; ++x) { |
| 20 | + assert.commandWorked(db[collName].insert({_id: x, a: 1})); |
| 21 | + } |
| 22 | + |
| 23 | + assert.commandWorked(db[collName].createIndex({a: 1})); |
| 24 | + |
| 25 | + // |
| 26 | + // Test find command. |
| 27 | + // |
| 28 | + let res = db.runCommand({find: collName, filter: {a: 1}, batchSize: 1}); |
| 29 | + assert.eq(1, res.cursor.firstBatch.length, tojson(res)); |
| 30 | + |
| 31 | + // Configure the failpoint to trip once, when the getMore command restores the cursor. |
| 32 | + let fp1 = configureFailPoint(db, "throwDuringIndexScanRestore", {} /* data */, {times: 1}); |
| 33 | + |
| 34 | + let getMoreRes = |
| 35 | + assert.commandWorked(db.runCommand({getMore: res.cursor.id, collection: collName})); |
| 36 | + assert.eq(4, getMoreRes.cursor.nextBatch.length, tojson(getMoreRes)); |
| 37 | + |
| 38 | + // |
| 39 | + // Test aggregate command. |
| 40 | + // |
| 41 | + res = |
| 42 | + db.runCommand({aggregate: collName, pipeline: [{$match: {a: 1}}], cursor: {batchSize: 1}}); |
| 43 | + assert.eq(1, res.cursor.firstBatch.length, tojson(res)); |
| 44 | + |
| 45 | + // Configure the failpoint to trip once, when the getMore command restores the cursor. |
| 46 | + let fp2 = configureFailPoint(db, "throwDuringIndexScanRestore", {} /* data */, {times: 1}); |
| 47 | + getMoreRes = |
| 48 | + assert.commandWorked(db.runCommand({getMore: res.cursor.id, collection: collName})); |
| 49 | + assert.eq(4, getMoreRes.cursor.nextBatch.length, tojson(getMoreRes)); |
| 50 | + |
| 51 | + // |
| 52 | + // Test batched delete command. |
| 53 | + // |
| 54 | + |
| 55 | + // Configure the fail point to trip once. |
| 56 | + let fp3 = configureFailPoint( |
| 57 | + db, "batchedDeleteStageThrowTemporarilyUnavailableException", {} /* data */, {times: 1}); |
| 58 | + assert.commandWorked(db[collName].remove({})); |
| 59 | +} |
| 60 | + |
| 61 | +// Fetch current value of 'internalQueryFrameworkControl' parameter. |
| 62 | +const previousQueryFrameworkControlValue = |
| 63 | + assert.commandWorked(db.adminCommand({getParameter: 1, internalQueryFrameworkControl: 1})) |
| 64 | + .internalQueryFrameworkControl; |
| 65 | + |
| 66 | +// Force query engine to classic for this test, as SBE does not yield for queries test here. |
| 67 | +assert.commandWorked( |
| 68 | + db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "forceClassicEngine"})); |
| 69 | + |
| 70 | +try { |
| 71 | + // Run actual test. |
| 72 | + runTest(); |
| 73 | +} finally { |
| 74 | + // Restore previous configuration of 'internalQueryFrameworkControl' parameter. |
| 75 | + assert.commandWorked(db.adminCommand( |
| 76 | + {setParameter: 1, internalQueryFrameworkControl: previousQueryFrameworkControlValue})); |
| 77 | +} |
| 78 | + |
| 79 | +MongoRunner.stopMongod(conn); |
0 commit comments