Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-24364

Implement MetadataManager to manage CollectionMetadata instances

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.9
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Fully Compatible
    • Sharding 16 (06/24/16)

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

            Assignee:
            leon.zaruvinsky Leon Zaruvinsky
            Reporter:
            crystal.horn@mongodb.com Crystal Horn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: