diff options
author | lukebhan <luke.bhan@vanderbilt.edu> | 2021-07-13 02:57:30 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-28 14:59:51 +0000 |
commit | b29131246ca7f24f1841436f34ba45c0d9df1540 (patch) | |
tree | 2c5e3cb4949dc28fd66fb11af632eb869d95477d | |
parent | 5d8c691143a7abe65811b05c3248252f57d9e6da (diff) | |
download | mongo-b29131246ca7f24f1841436f34ba45c0d9df1540.tar.gz |
SERVER-57729 Fixed namespace error when dropping a collection
fixed linter
ts bucket fix
fixed test
Deleted empty line changed collection name
fixed test naming
(cherry picked from commit 2bcc9f7efcebb86928a84008f26cccb4843da040)
-rw-r--r-- | jstests/core/timeseries/timeseries_bucket_drop.js | 38 | ||||
-rw-r--r-- | src/mongo/db/catalog/drop_collection.cpp | 4 |
2 files changed, 40 insertions, 2 deletions
diff --git a/jstests/core/timeseries/timeseries_bucket_drop.js b/jstests/core/timeseries/timeseries_bucket_drop.js new file mode 100644 index 00000000000..f77058731c1 --- /dev/null +++ b/jstests/core/timeseries/timeseries_bucket_drop.js @@ -0,0 +1,38 @@ +/** + * Tests dropping the bucket collection still results in a collection existing and being droppable + * + * @tags: [ + * assumes_no_implicit_collection_creation_after_drop, + * does_not_support_stepdowns, + * does_not_support_transactions, + * requires_fcv_49, + * requires_getmore, + * ] + */ + +(function() { +"use strict"; + +load("jstests/core/timeseries/libs/timeseries.js"); +TimeseriesTest.run((insert) => { + const testDB = db.getSiblingDB(jsTestName()); + assert.commandWorked(testDB.dropDatabase()); + + const coll = testDB.timeseries_bucket_drop; + const buckets = testDB.getCollection('system.buckets.' + coll.getName()); + assert.commandWorked( + testDB.createCollection(coll.getName(), {timeseries: {timeField: 'time'}})); + // Drop the buckets first + assert.commandWorked(testDB.runCommand({drop: buckets.getName()})); + let collections = + assert.commandWorked(testDB.runCommand({listCollections: 1})).cursor.firstBatch; + // Check that we delete bucket but not collection + assert.isnull(collections.find(entry => entry.name == buckets.getName())); + assert(collections.find(entry => entry.name == coll.getName())); + // Still should be able to drop the collection + assert.commandWorked(testDB.runCommand({drop: coll.getName()})); + collections = assert.commandWorked(testDB.runCommand({listCollections: 1})).cursor.firstBatch; + assert.isnull(collections.find(entry => entry.name == buckets.getName())); + assert.isnull(collections.find(entry => entry.name == coll.getName())); +}); +})(); diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp index 5377d433fe2..f7c672d7f29 100644 --- a/src/mongo/db/catalog/drop_collection.cpp +++ b/src/mongo/db/catalog/drop_collection.cpp @@ -375,8 +375,8 @@ Status dropCollection(OperationContext* opCtx, audit::logDropView(opCtx->getClient(), collectionName, "", {}, status.code()); return status; } - - if (view->timeseries()) { + if (view->timeseries() && + CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, view->viewOn())) { return dropTimeseries(view->viewOn(), true); } |