summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2016-11-22 16:53:05 -0500
committerGeert Bosch <geert@mongodb.com>2017-02-03 09:57:17 -0500
commit459fd0955603607b2d3d8763beacfc4e317aac33 (patch)
treea97a3f41c5cb93a25ef743cd48649777c949c430 /src/mongo/db/storage
parent76c9a2c0cf6bb6d7b63ccbef96e2d31ac36014c7 (diff)
downloadmongo-459fd0955603607b2d3d8763beacfc4e317aac33.tar.gz
SERVER-24963 Fix invalidation of cursors on system.indexes
(cherry picked from commit 647ebfac9ebf1c5fc431a2ba813bf9c97b9bdab9)
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp12
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 94cf75d1fde..7a54f771fa6 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"
@@ -257,6 +259,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);