summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/rollback_wt_drop.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/rollback_wt_drop.js')
-rw-r--r--jstests/noPassthrough/rollback_wt_drop.js62
1 files changed, 60 insertions, 2 deletions
diff --git a/jstests/noPassthrough/rollback_wt_drop.js b/jstests/noPassthrough/rollback_wt_drop.js
index 7df3d3fd9a0..e98708de58b 100644
--- a/jstests/noPassthrough/rollback_wt_drop.js
+++ b/jstests/noPassthrough/rollback_wt_drop.js
@@ -17,18 +17,34 @@
// Operations that will be present on both nodes, before the common point.
const collName = 'test.t';
+ const renameTargetCollName = 'test.x';
+ const noOpsToRollbackCollName = 'test.k';
let CommonOps = (node) => {
const coll = node.getCollection(collName);
const mydb = coll.getDB();
assert.commandWorked(mydb.createCollection(coll.getName()));
assert.commandWorked(coll.createIndex({a: 1}));
- assert.writeOK(coll.insert({_id: 0, a: 0}));
+ assert.commandWorked(coll.insert({_id: 0, a: 0}));
// Replicate a drop.
const replicatedDropCollName = 'w';
const collToDrop = mydb.getCollection(replicatedDropCollName);
assert.commandWorked(mydb.createCollection(collToDrop.getName()));
assert(collToDrop.drop());
+
+ // This collection will be dropped during a rename.
+ const renameTargetColl = node.getCollection(renameTargetCollName);
+ assert.commandWorked(mydb.createCollection(renameTargetColl.getName()));
+ assert.commandWorked(renameTargetColl.createIndex({b: 1}));
+ assert.commandWorked(renameTargetColl.insert({_id: 8, b: 8}));
+ assert.commandWorked(renameTargetColl.insert({_id: 9, b: 9}));
+
+ // This collection will be dropped without any CRUD ops to rollback.
+ const noOpsToRollbackColl = node.getCollection(noOpsToRollbackCollName);
+ assert.commandWorked(mydb.createCollection(noOpsToRollbackColl.getName()));
+ assert.commandWorked(noOpsToRollbackColl.createIndex({c: 1}));
+ assert.commandWorked(noOpsToRollbackColl.insert({_id: 20, c: 20}));
+ assert.commandWorked(noOpsToRollbackColl.insert({_id: 21, c: 21}));
};
// Operations that will be performed on the rollback node past the common point.
@@ -36,7 +52,7 @@
const coll = node.getCollection(collName);
// Rollback algorithm may refer to dropped collection if it has to undo an insert.
- assert.writeOK(coll.insert({_id: 1, a: 1}));
+ assert.commandWorked(coll.insert({_id: 1, a: 1}));
const mydb = coll.getDB();
const collectionsBeforeDrop = listCollections(mydb);
@@ -60,6 +76,22 @@
tojson(collectionsAfterDrop));
}
+ const renameTargetColl = node.getCollection(renameTargetCollName);
+ assert.commandWorked(renameTargetColl.insert({_id: 10, b: 10}));
+ assert.commandWorked(renameTargetColl.insert({_id: 11, b: 11}));
+ const renameSourceColl = mydb.getCollection('z');
+ assert.commandWorked(mydb.createCollection(renameSourceColl.getName()));
+ assert.commandWorked(renameSourceColl.renameCollection(renameTargetColl.getName(), true));
+
+ const noOpsToRollbackColl = node.getCollection(noOpsToRollbackCollName);
+ assert(noOpsToRollbackColl.drop());
+
+ // This collection will not exist after rollback.
+ const tempColl = node.getCollection('test.a');
+ assert.commandWorked(mydb.createCollection(tempColl.getName()));
+ assert.commandWorked(tempColl.insert({_id: 100, y: 100}));
+ assert(tempColl.drop());
+
// restartCatalog should not remove drop-pending idents.
assert.commandWorked(mydb.adminCommand({restartCatalog: 1}));
};
@@ -71,6 +103,26 @@
const rollbackNode = rollbackTest.transitionToRollbackOperations();
RollbackOps(rollbackNode);
+ {
+ // Check collection drop oplog entry.
+ const replTest = rollbackTest.getTestFixture();
+ const ops = replTest.dumpOplog(rollbackNode, {ns: 'test.$cmd', 'o.drop': 't'});
+ assert.eq(1, ops.length);
+ const op = ops[0];
+ assert(!op.hasOwnProperty('o2'), 'unexpected o2 field in drop oplog entry: ' + tojson(op));
+ }
+
+ // Check collection rename oplog entry.
+ {
+ const replTest = rollbackTest.getTestFixture();
+ const ops = replTest.dumpOplog(
+ rollbackNode, {ns: 'test.$cmd', 'o.renameCollection': 'test.z', 'o.to': 'test.x'});
+ assert.eq(1, ops.length);
+ const op = ops[0];
+ assert(!op.hasOwnProperty('o2'),
+ 'unexpected o2 field in rename oplog entry: ' + tojson(op));
+ }
+
// Wait for rollback to finish.
rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
rollbackTest.transitionToSyncSourceOperationsDuringRollback();
@@ -81,6 +133,12 @@
const coll = primary.getCollection(collName);
assert.eq(1, coll.find().itcount());
assert.eq(1, coll.count());
+ const renameTargetColl = primary.getCollection(renameTargetCollName);
+ assert.eq(2, renameTargetColl.find().itcount());
+ assert.eq(2, renameTargetColl.count());
+ const noOpsToRollbackColl = primary.getCollection(noOpsToRollbackCollName);
+ assert.eq(2, noOpsToRollbackColl.find().itcount());
+ assert.eq(2, noOpsToRollbackColl.count());
rollbackTest.stop();
})();