This ticket is to implement the class MetadataManager to track all variants of CollectionMetadata that are in use by operations currently running on a shard. Each CollectionShardingState will have a MetadataManager instance, which will maintain a counter for each CollectionMetadata of how many users there are of that particular metadata.
As part of this work, also unit-tests should be written for the MetadataManager class.
The interface should be something along the lines of:
class MetadataManager { public: /** * Increments the usage counter of the active metadata and returns a RAII object, which contains the currently active * metadata. When the RAII object goes out of scope it will call removeMetadataUser. */ ScopedCollectionMetadata getActiveMetadata(); /** * Changes the active metadata and if there are current users of the current active metadata puts it on the * _metadataInUse set. */ void setActiveMetadata(std::unique_ptr<CollectionMetadata> newActiveMetadata); /** * Decrements the usage counter of the specified metadata tracker and if that count is zero and the tracker is on the * _metadataInUse set, removes it from there. */ void removeMetadataUsage(CollectionMetadataTracker* metadataTracker); private: struct CollectionMetadataTracker { std::unique_ptr<CollectionMetadata> metadata; uint32_t usageCounter; }; friend class ScopedCollectionMetadata; CollectionMetadataTracker _activeMetadata; std::set<CollectionMetadataTracker> _metadataInUse; };
- has to be done after
-
SERVER-24461 Create MetadataManager class
- Closed
- has to be done before
-
SERVER-24415 Remove usages of shared_ptr<CollectionMetadata>
- Closed