summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp')
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp
index f6e0e6c185c..b46a632fd5c 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp
+++ b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp
@@ -311,12 +311,7 @@ Status MMAPV1DatabaseCatalogEntry::renameCollection(OperationContext* txn,
return s;
}
// Invalidate index record for the old collection.
- StringData dbName(nsToDatabaseSubstring(_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, record->id, INVALIDATION_DELETION);
+ invalidateSystemCollectionRecord(txn, NamespaceString(name(), "system.indexes"), loc);
systemIndexRecordStore->deleteRecord(txn, loc);
}
@@ -384,13 +379,8 @@ Status MMAPV1DatabaseCatalogEntry::_renameSingleNamespace(OperationContext* txn,
RecordId rid = _addNamespaceToNamespaceCollection(txn, toNS, newSpec.isEmpty() ? 0 : &newSpec);
// Invalidate old namespace record
- const NamespaceString nsn(name(), "system.namespaces");
- StringData dbName(name());
- invariant(txn->lockState()->isDbLockedForMode(dbName, MODE_X));
- Database* db = dbHolder().get(txn, dbName);
- Collection* systemNamespaces = db->getCollection(nsn);
- systemNamespaces->getCursorManager()->invalidateDocument(
- txn, oldSpecLocation, INVALIDATION_DELETION);
+ invalidateSystemCollectionRecord(
+ txn, NamespaceString(name(), "system.namespaces"), oldSpecLocation);
_getNamespaceRecordStore()->deleteRecord(txn, oldSpecLocation);
@@ -404,6 +394,17 @@ Status MMAPV1DatabaseCatalogEntry::_renameSingleNamespace(OperationContext* txn,
return Status::OK();
}
+void MMAPV1DatabaseCatalogEntry::invalidateSystemCollectionRecord(
+ OperationContext* txn, NamespaceString systemCollectionNamespace, RecordId record) {
+ // 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.
+ StringData dbName = systemCollectionNamespace.db();
+ invariant(txn->lockState()->isDbLockedForMode(dbName, MODE_X));
+ Database* db = dbHolder().get(txn, dbName);
+ Collection* systemCollection = db->getCollection(systemCollectionNamespace);
+ systemCollection->getCursorManager()->invalidateDocument(txn, record, INVALIDATION_DELETION);
+}
+
void MMAPV1DatabaseCatalogEntry::appendExtraStats(OperationContext* opCtx,
BSONObjBuilder* output,
double scale) const {
@@ -822,13 +823,8 @@ void MMAPV1DatabaseCatalogEntry::_removeNamespaceFromNamespaceCollection(Operati
// Invalidate old namespace record
RecordId oldSpecLocation = entry->second->catalogEntry->getNamespacesRecordId();
- const NamespaceString nsn(name(), "system.namespaces");
- StringData dbName(name());
- invariant(txn->lockState()->isDbLockedForMode(dbName, MODE_X));
- Database* db = dbHolder().get(txn, dbName);
- Collection* systemNamespaces = db->getCollection(nsn);
- systemNamespaces->getCursorManager()->invalidateDocument(
- txn, oldSpecLocation, INVALIDATION_DELETION);
+ invalidateSystemCollectionRecord(
+ txn, NamespaceString(name(), "system.namespaces"), oldSpecLocation);
rs->deleteRecord(txn, oldSpecLocation);
}