Storage Engine API
mongo::KVCatalog::FeatureTracker Class Reference

Manages the contents of a document in the KVCatalog used to restrict downgrade compatibility. More...

#include <kv_catalog_feature_tracker.h>

Detailed Description

Manages the contents of a document in the KVCatalog used to restrict downgrade compatibility.

When a new feature is enabled on a collection or index in the data files, a bit is set in one of the fields of the document. Older versions won't recognize this bit and will fail to start up as a result.

The inserted document serves a similar purpose to the DataFileVersion class used with the MMAPv1 storage engine.

Classes

struct  FeatureBits
 

Public Types

enum  NonRepairableFeature : std::uint64_t { NonRepairableFeature::kCollation = 1 << 0, NonRepairableFeature::kNextFeatureBit = 1 << 1 }
 Bit flags representing whether a particular feature is enabled on a least one collection or index in the data files. More...
 
enum  RepairableFeature : std::uint64_t { RepairableFeature::kPathLevelMultikeyTracking = 1 << 0, RepairableFeature::kNextFeatureBit = 1 << 1 }
 Bit flags representing whether a particular feature is enabled on a least one collection or index in the data files. More...
 
using NonRepairableFeatureMask = std::underlying_type< NonRepairableFeature >::type
 
using RepairableFeatureMask = std::underlying_type< RepairableFeature >::type
 

Public Member Functions

Status isCompatibleWithCurrentCode (OperationContext *opCtx) const
 Returns whethers the data files are compatible with the current code: More...
 
bool isNonRepairableFeatureInUse (OperationContext *opCtx, NonRepairableFeature feature) const
 Returns true if 'feature' is tracked in the document, and returns false otherwise. More...
 
void markNonRepairableFeatureAsInUse (OperationContext *opCtx, NonRepairableFeature feature)
 Sets the specified non-repairable feature as being enabled on at least one collection or index in the data files. More...
 
void markNonRepairableFeatureAsNotInUse (OperationContext *opCtx, NonRepairableFeature feature)
 Sets the specified non-repairable feature as not being enabled on any collection or index in the data files. More...
 
bool isRepairableFeatureInUse (OperationContext *opCtx, RepairableFeature feature) const
 Returns true if 'feature' is tracked in the document, and returns false otherwise. More...
 
void markRepairableFeatureAsInUse (OperationContext *opCtx, RepairableFeature feature)
 Sets the specified repairable feature as being enabled on at least one collection or index in the data files. More...
 
void markRepairableFeatureAsNotInUse (OperationContext *opCtx, RepairableFeature feature)
 Sets the specified repairable feature as not being enabled on any collection or index in the data files. More...
 
void setUsedNonRepairableFeaturesMaskForTestingOnly (NonRepairableFeatureMask mask)
 
void setUsedRepairableFeaturesMaskForTestingOnly (RepairableFeatureMask mask)
 
FeatureBits getInfo (OperationContext *opCtx) const
 
void putInfo (OperationContext *opCtx, const FeatureBits &versionInfo)
 

Static Public Member Functions

static bool isFeatureDocument (BSONObj obj)
 Returns true if 'obj' represents the contents of the feature document that was previously inserted into the KVCatalog, and returns false otherwise. More...
 
static std::unique_ptr< FeatureTrackerget (OperationContext *opCtx, KVCatalog *catalog, RecordId rid)
 Returns a FeatureTracker instance to manage the contents of the feature document located at 'rid' in the record store 'catalog->_rs'. More...
 
static std::unique_ptr< FeatureTrackercreate (OperationContext *opCtx, KVCatalog *catalog)
 Returns a FeatureTracker instance to manage the contents of a feature document. More...
 

Private Member Functions

 FeatureTracker (KVCatalog *catalog, RecordId rid)
 

Private Attributes

KVCatalog_catalog
 
RecordId _rid
 
NonRepairableFeatureMask _usedNonRepairableFeaturesMask
 
RepairableFeatureMask _usedRepairableFeaturesMask
 

Member Typedef Documentation

◆ NonRepairableFeatureMask

◆ RepairableFeatureMask

Member Enumeration Documentation

◆ NonRepairableFeature

Bit flags representing whether a particular feature is enabled on a least one collection or index in the data files.

Features included in this enumeration always require user intervention on downgrade.

The next feature added to this enumeration should use the current value of 'kNextFeatureBit', and 'kNextFeatureBit' should be changed to the next largest power of two.

Enumerator
kCollation 
kNextFeatureBit 

◆ RepairableFeature

Bit flags representing whether a particular feature is enabled on a least one collection or index in the data files.

Features included in this enumeration either (a) don't require user intervention on downgrade, or (b) are no longer enabled if –repair is done with an older version.

The next feature added to this enumeration should use the current value of 'kNextFeatureBit', and 'kNextFeatureBit' should be changed to the next largest power of two.

Enumerator
kPathLevelMultikeyTracking 
kNextFeatureBit 

Constructor & Destructor Documentation

◆ FeatureTracker()

mongo::KVCatalog::FeatureTracker::FeatureTracker ( KVCatalog catalog,
RecordId  rid 
)
inlineprivate

Member Function Documentation

◆ create()

std::unique_ptr< KVCatalog::FeatureTracker > mongo::KVCatalog::FeatureTracker::create ( OperationContext *  opCtx,
KVCatalog catalog 
)
static

Returns a FeatureTracker instance to manage the contents of a feature document.

The feature document isn't inserted into 'rs' as a result of calling this function. Instead, the feature document is inserted into 'rs' when putInfo() is first called.

It is invalid to call this function when isFeatureDocument() returns true for some document in the record store 'catalog->_rs'.

◆ get()

std::unique_ptr< KVCatalog::FeatureTracker > mongo::KVCatalog::FeatureTracker::get ( OperationContext *  opCtx,
KVCatalog catalog,
RecordId  rid 
)
static

Returns a FeatureTracker instance to manage the contents of the feature document located at 'rid' in the record store 'catalog->_rs'.

It is invalid to call this function when isFeatureDocument() returns false for the record data associated with 'rid'.

◆ getInfo()

KVCatalog::FeatureTracker::FeatureBits mongo::KVCatalog::FeatureTracker::getInfo ( OperationContext *  opCtx) const

◆ isCompatibleWithCurrentCode()

Status mongo::KVCatalog::FeatureTracker::isCompatibleWithCurrentCode ( OperationContext *  opCtx) const

Returns whethers the data files are compatible with the current code:

  • Status::OK() if the data files are compatible with the current code.
  • ErrorCodes::CanRepairToDowngrade if the data files are incompatible with the current code, but a –repair would make them compatible. For example, when rebuilding all indexes in the data files would resolve the incompatibility.
  • ErrorCodes::MustUpgrade if the data files are incompatible with the current code and a newer version is required to start up.

◆ isFeatureDocument()

bool mongo::KVCatalog::FeatureTracker::isFeatureDocument ( BSONObj  obj)
static

Returns true if 'obj' represents the contents of the feature document that was previously inserted into the KVCatalog, and returns false otherwise.

This function should return true for at most one document in the KVCatalog.

◆ isNonRepairableFeatureInUse()

bool mongo::KVCatalog::FeatureTracker::isNonRepairableFeatureInUse ( OperationContext *  opCtx,
NonRepairableFeature  feature 
) const

Returns true if 'feature' is tracked in the document, and returns false otherwise.

◆ isRepairableFeatureInUse()

bool mongo::KVCatalog::FeatureTracker::isRepairableFeatureInUse ( OperationContext *  opCtx,
RepairableFeature  feature 
) const

Returns true if 'feature' is tracked in the document, and returns false otherwise.

◆ markNonRepairableFeatureAsInUse()

void mongo::KVCatalog::FeatureTracker::markNonRepairableFeatureAsInUse ( OperationContext *  opCtx,
NonRepairableFeature  feature 
)

Sets the specified non-repairable feature as being enabled on at least one collection or index in the data files.

◆ markNonRepairableFeatureAsNotInUse()

void mongo::KVCatalog::FeatureTracker::markNonRepairableFeatureAsNotInUse ( OperationContext *  opCtx,
NonRepairableFeature  feature 
)

Sets the specified non-repairable feature as not being enabled on any collection or index in the data files.

◆ markRepairableFeatureAsInUse()

void mongo::KVCatalog::FeatureTracker::markRepairableFeatureAsInUse ( OperationContext *  opCtx,
RepairableFeature  feature 
)

Sets the specified repairable feature as being enabled on at least one collection or index in the data files.

◆ markRepairableFeatureAsNotInUse()

void mongo::KVCatalog::FeatureTracker::markRepairableFeatureAsNotInUse ( OperationContext *  opCtx,
RepairableFeature  feature 
)

Sets the specified repairable feature as not being enabled on any collection or index in the data files.

◆ putInfo()

void mongo::KVCatalog::FeatureTracker::putInfo ( OperationContext *  opCtx,
const FeatureBits versionInfo 
)

◆ setUsedNonRepairableFeaturesMaskForTestingOnly()

void mongo::KVCatalog::FeatureTracker::setUsedNonRepairableFeaturesMaskForTestingOnly ( NonRepairableFeatureMask  mask)
inline

◆ setUsedRepairableFeaturesMaskForTestingOnly()

void mongo::KVCatalog::FeatureTracker::setUsedRepairableFeaturesMaskForTestingOnly ( RepairableFeatureMask  mask)
inline

Member Data Documentation

◆ _catalog

KVCatalog* mongo::KVCatalog::FeatureTracker::_catalog
private

◆ _rid

RecordId mongo::KVCatalog::FeatureTracker::_rid
private

◆ _usedNonRepairableFeaturesMask

NonRepairableFeatureMask mongo::KVCatalog::FeatureTracker::_usedNonRepairableFeaturesMask
private

◆ _usedRepairableFeaturesMask

RepairableFeatureMask mongo::KVCatalog::FeatureTracker::_usedRepairableFeaturesMask
private
Initial value:

The documentation for this class was generated from the following files: