summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2020-02-21 09:49:30 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-25 02:48:51 +0000
commitbc4caba144ed5a422609a8400e1ba8cb5a88810a (patch)
tree5e29cf6eb20d3b8a2b85206080413a1df087ecf6 /jstests/noPassthroughWithMongod
parent0aac1805c04aa5b1481ba99dcab2273d423df10c (diff)
downloadmongo-bc4caba144ed5a422609a8400e1ba8cb5a88810a.tar.gz
SERVER-46196 Fix creation of orphan Top entries on failed collection creation
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js b/jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js
index 82cfa2b8bf6..cdfd1bcfc29 100644
--- a/jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js
+++ b/jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js
@@ -75,9 +75,16 @@ let smallCollName = 'd'.repeat(10000);
assert.commandWorked(testDB.createCollection(smallCollName));
let smallColl = testDB.getCollection(smallCollName);
-// The 'top' command should fail because the response would be too big to return.
-assert.commandFailedWithCode(largeColl.getDB().adminCommand('top'),
- [13548, ErrorCodes.BSONObjectTooLarge]);
+// The 'top' command should succeed even with a long collection name.
+assert.commandWorked(largeColl.getDB().adminCommand('top'));
+
+// We should be able to add another collection with a long name successfully. After doing so, then
+// the amount of data which Top needs to return will exceed the maximum BSON size, causing the
+// command to fail.
+const secondLargeCollName = 'e'.repeat(largeColl.getName().length);
+assert.commandWorked(testDB.createCollection(secondLargeCollName));
+const secondLargeColl = testDB.getCollection(secondLargeCollName);
+assert.commandFailedWithCode(testDB.adminCommand('top'), [13548, ErrorCodes.BSONObjectTooLarge]);
// Adding indexes to the large collection should fail but not crash the server.
assert.commandFailedWithCode(largeColl.createIndex({x: 1}), ErrorCodes.BSONObjectTooLarge);
@@ -100,7 +107,7 @@ assert.commandWorked(adminDB.runCommand(
// Renaming the small collection should fail because it has one more index than the large
// collection.
let otherLargeCollName = 'modify_metadata_when_full.' +
- 'e'.repeat(largeColl.getName().length);
+ 'f'.repeat(largeColl.getName().length);
assert.commandFailedWithCode(
adminDB.runCommand({renameCollection: smallColl.getFullName(), to: otherLargeCollName}),
ErrorCodes.BSONObjectTooLarge);
@@ -108,4 +115,5 @@ assert.commandFailedWithCode(
// Dropping both collections should work.
assert.eq(true, largeColl.drop());
assert.eq(true, smallColl.drop());
+assert.eq(true, secondLargeColl.drop());
}());