diff options
author | Geert Bosch <geert@mongodb.com> | 2016-11-22 16:53:05 -0500 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2017-01-31 14:49:15 -0500 |
commit | 29b442a74b8f4ad8d3d9b0cba29fbeafac0abcfa (patch) | |
tree | 4c83c6281bc3fbcb80e8f4713b38220dbd56bdc2 /src | |
parent | 96f846f8ffcf44dc4edf272b1af6e9cb8a898239 (diff) | |
download | mongo-29b442a74b8f4ad8d3d9b0cba29fbeafac0abcfa.tar.gz |
SERVER-24963 Fix invalidation of cursors on system.indexes
(cherry picked from commit 647ebfac9ebf1c5fc431a2ba813bf9c97b9bdab9)
Conflicts:
jstests/readonly/lib/read_only_test.js
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp index 5cfda64a2af..2d9a2138542 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp @@ -32,6 +32,8 @@ #include "mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h" +#include "mongo/db/catalog/database.h" +#include "mongo/db/catalog/database_holder.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/ops/update.h" #include "mongo/db/record_id.h" @@ -251,6 +253,16 @@ Status NamespaceDetailsCollectionCatalogEntry::removeIndex(OperationContext* txn d->idx(getTotalIndexCount(txn)) = IndexDetails(); } + // Soneone may be querying the system.indexes namespace directly, so we need to invalidate + // its cursors. Having to go back up through the DatabaseHolder is a bit of a layering + // violation, but at this point we're not going to add more MMAPv1 specific interfaces. + // We can find the name of the database through the first entries of the CollectionMap. + StringData dbName(nsToDatabaseSubstring(_db->_collections.begin()->first)); + invariant(txn->lockState()->isDbLockedForMode(dbName, MODE_X)); + Database* db = dbHolder().get(txn, dbName); + Collection* systemIndexes = db->getCollection(db->getSystemIndexesName()); + systemIndexes->getCursorManager()->invalidateDocument(txn, infoLocation, INVALIDATION_DELETION); + // remove from system.indexes _indexRecordStore->deleteRecord(txn, infoLocation); |