diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-04-10 11:05:34 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-10 17:05:40 +0000 |
commit | 5abfdd53a7508d17ce6ca0ca0447d3e13ddc746d (patch) | |
tree | ad895eb47b8ece614182e39e429390a4f678d439 | |
parent | 905011e695e1886d9fb733f71975a3affe5f4f85 (diff) | |
download | mongo-5abfdd53a7508d17ce6ca0ca0447d3e13ddc746d.tar.gz |
SERVER-47087 dropDatabase interrupted due to a replication state change must reset the dropPending flag before exiting
-rw-r--r-- | jstests/noPassthrough/drop_database_after_stepdown_resets_drop_pending_flag.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/jstests/noPassthrough/drop_database_after_stepdown_resets_drop_pending_flag.js b/jstests/noPassthrough/drop_database_after_stepdown_resets_drop_pending_flag.js new file mode 100644 index 00000000000..fb3ef31456d --- /dev/null +++ b/jstests/noPassthrough/drop_database_after_stepdown_resets_drop_pending_flag.js @@ -0,0 +1,75 @@ +/** + * Verifies that a dropDatabase operation interrupted due to stepping down resets the drop pending + * flag. Additionally, after the node steps down, we ensure it can drop the database as instructed + * by the new primary. + * + * @tags: [requires_replication] + */ +(function() { +"use strict"; + +load('jstests/noPassthrough/libs/index_build.js'); + +const rst = new ReplSetTest({ + nodes: [ + {}, + {}, + ] +}); +rst.startSet(); +rst.initiate(); + +const primary = rst.getPrimary(); + +if (!IndexBuildTest.supportsTwoPhaseIndexBuild(primary)) { + jsTestLog('Two phase index builds not supported, skipping test.'); + rst.stopSet(); + return; +} + +const testDB = primary.getDB('test'); +const coll = testDB.getCollection('test'); + +assert.commandWorked(testDB.adminCommand( + {configureFailPoint: 'dropDatabaseHangAfterWaitingForIndexBuilds', mode: 'alwaysOn'})); + +assert.commandWorked(coll.insert({a: 1})); + +IndexBuildTest.pauseIndexBuilds(primary); + +let awaitIndexBuild = startParallelShell(() => { + const coll = db.getSiblingDB('test').getCollection('test'); + assert.commandFailedWithCode(coll.createIndex({a: 1}), ErrorCodes.IndexBuildAborted); +}, primary.port); + +IndexBuildTest.waitForIndexBuildToStart(testDB, coll.getName(), "a_1"); + +let awaitDropDatabase = startParallelShell(() => { + assert.commandFailedWithCode(db.getSiblingDB('test').dropDatabase(), + ErrorCodes.InterruptedDueToReplStateChange); +}, primary.port); + +checkLog.containsJson(primary, 4612300); + +assert.commandWorked(testDB.adminCommand({clearLog: "global"})); +let awaitStepDown = startParallelShell(() => { + assert.commandWorked(db.adminCommand({replSetStepDown: 30})); +}, primary.port); + +IndexBuildTest.resumeIndexBuilds(primary); + +checkLog.containsJson(primary, 21344); +assert.commandWorked(testDB.adminCommand( + {configureFailPoint: 'dropDatabaseHangAfterWaitingForIndexBuilds', mode: 'off'})); + +awaitIndexBuild(); +awaitDropDatabase(); +awaitStepDown(); + +rst.awaitReplication(); + +// Have the new primary try to drop the database. The stepped down node must successfully replicate +// this dropDatabase command. +assert.commandWorked(rst.getPrimary().getDB('test').dropDatabase()); +rst.stopSet(); +})(); |