Storage Engine API
kv_catalog_feature_tracker.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <cstdint>
32 #include <memory>
33 #include <type_traits>
34 
36 
37 namespace mongo {
38 
39 class OperationContext;
40 class RecordId;
41 class RecordStore;
42 
54 public:
63  enum class NonRepairableFeature : std::uint64_t {
64  kCollation = 1 << 0,
65  kNextFeatureBit = 1 << 1
66  };
67 
68  using NonRepairableFeatureMask = std::underlying_type<NonRepairableFeature>::type;
69 
79  enum class RepairableFeature : std::uint64_t {
80  kPathLevelMultikeyTracking = 1 << 0,
81  kNextFeatureBit = 1 << 1
82  };
83 
84  using RepairableFeatureMask = std::underlying_type<RepairableFeature>::type;
85 
92  static bool isFeatureDocument(BSONObj obj);
93 
101  static std::unique_ptr<FeatureTracker> get(OperationContext* opCtx,
102  KVCatalog* catalog,
103  RecordId rid);
104 
113  static std::unique_ptr<FeatureTracker> create(OperationContext* opCtx, KVCatalog* catalog);
114 
127  Status isCompatibleWithCurrentCode(OperationContext* opCtx) const;
128 
132  bool isNonRepairableFeatureInUse(OperationContext* opCtx, NonRepairableFeature feature) const;
133 
138  void markNonRepairableFeatureAsInUse(OperationContext* opCtx, NonRepairableFeature feature);
139 
144  void markNonRepairableFeatureAsNotInUse(OperationContext* opCtx, NonRepairableFeature feature);
145 
149  bool isRepairableFeatureInUse(OperationContext* opCtx, RepairableFeature feature) const;
150 
155  void markRepairableFeatureAsInUse(OperationContext* opCtx, RepairableFeature feature);
156 
161  void markRepairableFeatureAsNotInUse(OperationContext* opCtx, RepairableFeature feature);
162 
165  }
166 
169  }
170 
171  struct FeatureBits {
174  };
175 
176  FeatureBits getInfo(OperationContext* opCtx) const;
177 
178  void putInfo(OperationContext* opCtx, const FeatureBits& versionInfo);
179 
180 private:
181  // Must go through FeatureTracker::get() or FeatureTracker::create().
182  FeatureTracker(KVCatalog* catalog, RecordId rid) : _catalog(catalog), _rid(rid) {}
183 
185  RecordId _rid;
186 
189 
192 };
193 
194 } // namespace mongo
NonRepairableFeature
Bit flags representing whether a particular feature is enabled on a least one collection or index in ...
Definition: kv_catalog_feature_tracker.h:63
NonRepairableFeatureMask nonRepairableFeatures
Definition: kv_catalog_feature_tracker.h:172
FeatureTracker(KVCatalog *catalog, RecordId rid)
Definition: kv_catalog_feature_tracker.h:182
KVCatalog * _catalog
Definition: kv_catalog_feature_tracker.h:184
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
void markRepairableFeatureAsInUse(OperationContext *opCtx, RepairableFeature feature)
Sets the specified repairable feature as being enabled on at least one collection or index in the dat...
Definition: kv_catalog.cpp:245
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
static bool isFeatureDocument(BSONObj obj)
Returns true if &#39;obj&#39; represents the contents of the feature document that was previously inserted in...
Definition: kv_catalog.cpp:168
void putInfo(OperationContext *opCtx, const FeatureBits &versionInfo)
Definition: kv_catalog.cpp:293
void setUsedRepairableFeaturesMaskForTestingOnly(RepairableFeatureMask mask)
Definition: kv_catalog_feature_tracker.h:167
void markNonRepairableFeatureAsInUse(OperationContext *opCtx, NonRepairableFeature feature)
Sets the specified non-repairable feature as being enabled on at least one collection or index in the...
Definition: kv_catalog.cpp:225
bool isRepairableFeatureInUse(OperationContext *opCtx, RepairableFeature feature) const
Returns true if &#39;feature&#39; is tracked in the document, and returns false otherwise.
Definition: kv_catalog.cpp:239
Definition: kv_catalog.h:49
RepairableFeatureMask repairableFeatures
Definition: kv_catalog_feature_tracker.h:173
std::underlying_type< RepairableFeature >::type RepairableFeatureMask
Definition: kv_catalog_feature_tracker.h:84
void markRepairableFeatureAsNotInUse(OperationContext *opCtx, RepairableFeature feature)
Sets the specified repairable feature as not being enabled on any collection or index in the data fil...
Definition: kv_catalog.cpp:252
bool isNonRepairableFeatureInUse(OperationContext *opCtx, NonRepairableFeature feature) const
Returns true if &#39;feature&#39; is tracked in the document, and returns false otherwise.
Definition: kv_catalog.cpp:219
Definition: kv_catalog_feature_tracker.h:171
void markNonRepairableFeatureAsNotInUse(OperationContext *opCtx, NonRepairableFeature feature)
Sets the specified non-repairable feature as not being enabled on any collection or index in the data...
Definition: kv_catalog.cpp:232
Manages the contents of a document in the KVCatalog used to restrict downgrade compatibility.
Definition: kv_catalog_feature_tracker.h:53
static std::unique_ptr< FeatureTracker > create(OperationContext *opCtx, KVCatalog *catalog)
Returns a FeatureTracker instance to manage the contents of a feature document.
Definition: kv_catalog.cpp:213
NonRepairableFeatureMask _usedNonRepairableFeaturesMask
Definition: kv_catalog_feature_tracker.h:187
std::underlying_type< NonRepairableFeature >::type NonRepairableFeatureMask
Definition: kv_catalog_feature_tracker.h:68
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
FeatureBits getInfo(OperationContext *opCtx) const
Definition: kv_catalog.cpp:259
RecordId _rid
Definition: kv_catalog_feature_tracker.h:185
RepairableFeatureMask _usedRepairableFeaturesMask
Definition: kv_catalog_feature_tracker.h:190
Status isCompatibleWithCurrentCode(OperationContext *opCtx) const
Returns whethers the data files are compatible with the current code:
Definition: kv_catalog.cpp:176
RepairableFeature
Bit flags representing whether a particular feature is enabled on a least one collection or index in ...
Definition: kv_catalog_feature_tracker.h:79
void setUsedNonRepairableFeaturesMaskForTestingOnly(NonRepairableFeatureMask mask)
Definition: kv_catalog_feature_tracker.h:163