[SERVER-24364] Implement MetadataManager to manage CollectionMetadata instances Created: 02/Jun/16  Updated: 05/Jul/16  Resolved: 17/Jun/16

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.3.9

Type: Task Priority: Major - P3
Reporter: Crystal Horn Assignee: Leon Zaruvinsky
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Gantt Dependency
has to be done before SERVER-24415 Remove usages of shared_ptr<Collectio... Closed
has to be done after SERVER-24461 Create MetadataManager class Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 16 (06/24/16)
Participants:

 Description   

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;
};



 Comments   
Comment by Githook User [ 17/Jun/16 ]

Author:

{u'username': u'leonz', u'name': u'Leon Zaruvinsky', u'email': u'leon@mongodb.com'}

Message: SERVER-24364 Implements MetadataManager to manage CollectionMetadata instances
Branch: master
https://github.com/mongodb/mongo/commit/5b9bbea85106f7b69bdb2e5578981c69fc4e3da8

Comment by Dianna Hohensee (Inactive) [ 08/Jun/16 ]

Will need to Implement a ScopedCollectionMetadata class. Roughly, something like,

class ScopedCollectionMetadata {
public:
    /**
     * Increments the counter in CollectionMetadataTracker.
     */
    ScopedCollectionMetadata(CollectionMetadataTracker*)  
 
    /**
     * Decrements the counter in CollectionMetadataTracker.
     */
    ~ScopedCollectionMetadata()
 
}

Also define a dereference operator that will go straight to the CollectionMetadata held in CollectionMetadataTracker, so something like this will work

scopedCollectionMetadata->cloneMigrate(...);

cloneMigrate is from CollectionMetadata::cloneMigrate.

Generated at Thu Feb 08 04:06:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.