Storage Engine API
mongo::AutoAcquireFlushLockForMMAPV1Commit Class Reference

This explains how the MMAP V1 durability system is implemented. More...

#include <lock_state.h>

Detailed Description

This explains how the MMAP V1 durability system is implemented.

Every server operation (OperationContext), must call Locker::lockGlobal as the first lock action (it is illegal to acquire any other locks without calling this first). This action acquires the global and flush locks in the appropriate modes (IS for read operations, IX for write operations). Having the flush lock in one of these modes indicates to the flush thread that there is an active reader or writer.

Whenever the flush thread(dur.cpp) activates, it goes through the following steps :

Acquire the flush lock in S mode using AutoAcquireFlushLockForMMAPV1Commit. This waits until all current write activity on the system completes and does not allow any new operations to start.

Once the S lock is granted, the flush thread writes the journal entries to disk (it is guaranteed that there will not be any modifications) and applies them to the shared view.

After that, it upgrades the S lock to X and remaps the private view.

NOTE: There should be only one usage of this class and this should be in dur.cpp

Public Member Functions

 AutoAcquireFlushLockForMMAPV1Commit (Locker *locker)
 
 ~AutoAcquireFlushLockForMMAPV1Commit ()
 
void upgradeFlushLockToExclusive ()
 We need the exclusive lock in order to do the shared view remap. More...
 
void release ()
 Allows the acquired flush lock to be prematurely released. More...
 

Private Attributes

Locker *const _locker
 
bool _released
 

Constructor & Destructor Documentation

◆ AutoAcquireFlushLockForMMAPV1Commit()

mongo::AutoAcquireFlushLockForMMAPV1Commit::AutoAcquireFlushLockForMMAPV1Commit ( Locker locker)

◆ ~AutoAcquireFlushLockForMMAPV1Commit()

mongo::AutoAcquireFlushLockForMMAPV1Commit::~AutoAcquireFlushLockForMMAPV1Commit ( )

Member Function Documentation

◆ release()

void mongo::AutoAcquireFlushLockForMMAPV1Commit::release ( )

Allows the acquired flush lock to be prematurely released.

This is helpful for the case where we know that we won't be doing a remap after gathering the write intents, so the rest can be done outside of flush lock.

◆ upgradeFlushLockToExclusive()

void mongo::AutoAcquireFlushLockForMMAPV1Commit::upgradeFlushLockToExclusive ( )

We need the exclusive lock in order to do the shared view remap.

Member Data Documentation

◆ _locker

Locker* const mongo::AutoAcquireFlushLockForMMAPV1Commit::_locker
private

◆ _released

bool mongo::AutoAcquireFlushLockForMMAPV1Commit::_released
private

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