Storage Engine API
mongo::dur::DurableInterface Class Referenceabstract

#include <dur.h>

Public Member Functions

virtual ~DurableInterface ()
 
virtual void createdFile (const std::string &filename, unsigned long long len)=0
 Declare that a file has been created. More...
 
virtual void declareWriteIntents (const std::vector< std::pair< void *, unsigned >> &intents)=0
 
virtual bool waitUntilDurable ()=0
 Wait for acknowledgement of the next group commit. More...
 
virtual bool commitNow (OperationContext *opCtx)=0
 Commit immediately. More...
 
virtual bool commitIfNeeded ()=0
 Commit if enough bytes have been modified. More...
 
virtual void closingFileNotification ()=0
 Called when a DurableMappedFile is closing. More...
 
virtual void commitAndStopDurThread (OperationContext *opCtx)=0
 Invoked at clean shutdown time. More...
 
virtual void syncDataAndTruncateJournal (OperationContext *opCtx)=0
 Commits pending changes, flushes all changes to main data files, then removes the journal. More...
 
virtual bool isDurable () const =0
 

Static Public Member Functions

static DurableInterfacegetDur ()
 

Protected Member Functions

 DurableInterface ()
 

Private Member Functions

 MONGO_DISALLOW_COPYING (DurableInterface)
 

Static Private Attributes

static DurableInterface_impl
 

Friends

void startup (ClockSource *cs, int64_t serverStartMs)
 Invoked at server startup. More...
 

Constructor & Destructor Documentation

◆ ~DurableInterface()

mongo::dur::DurableInterface::~DurableInterface ( )
virtual

◆ DurableInterface()

mongo::dur::DurableInterface::DurableInterface ( )
protected

Member Function Documentation

◆ closingFileNotification()

virtual void mongo::dur::DurableInterface::closingFileNotification ( )
pure virtual

Called when a DurableMappedFile is closing.

Asserts that there are no unwritten changes, because that would mean journal replay on recovery would try to write to non-existent files and fail.

◆ commitAndStopDurThread()

virtual void mongo::dur::DurableInterface::commitAndStopDurThread ( OperationContext *  opCtx)
pure virtual

Invoked at clean shutdown time.

Performs one last commit/flush and terminates the flush thread.

Must be called under the global X lock.

◆ commitIfNeeded()

virtual bool mongo::dur::DurableInterface::commitIfNeeded ( )
pure virtual

Commit if enough bytes have been modified.

Current threshold is 50MB

The idea is that long running write operations that don't yield (like creating an index) can call this whenever the db is in a sane state and it will prevent commits from growing too large.

Returns
true if commited

◆ commitNow()

virtual bool mongo::dur::DurableInterface::commitNow ( OperationContext *  opCtx)
pure virtual

Commit immediately.

Generally, you do not want to do this often, as highly granular committing may affect performance.

Does not return until the commit is complete.

You must be at least read locked when you call this. Ideally, you are not write locked and then read operations can occur concurrently.

Do not use this. Use commitIfNeeded() instead.

Returns
true if –dur is on.
false if –dur is off. (in which case there is action)

◆ createdFile()

virtual void mongo::dur::DurableInterface::createdFile ( const std::string &  filename,
unsigned long long  len 
)
pure virtual

Declare that a file has been created.

Normally writes are applied only after journaling for safety. But here the file is created first, and the journal will just replay the creation if the create didn't happen due to a crash.

◆ declareWriteIntents()

virtual void mongo::dur::DurableInterface::declareWriteIntents ( const std::vector< std::pair< void *, unsigned >> &  intents)
pure virtual

◆ getDur()

static DurableInterface& mongo::dur::DurableInterface::getDur ( )
inlinestatic

◆ isDurable()

virtual bool mongo::dur::DurableInterface::isDurable ( ) const
pure virtual

◆ MONGO_DISALLOW_COPYING()

mongo::dur::DurableInterface::MONGO_DISALLOW_COPYING ( DurableInterface  )
private

◆ syncDataAndTruncateJournal()

virtual void mongo::dur::DurableInterface::syncDataAndTruncateJournal ( OperationContext *  opCtx)
pure virtual

Commits pending changes, flushes all changes to main data files, then removes the journal.

WARNING: Data must be in a crash-recoverable state when this is called and must not be inside of a write unit of work.

This is useful as a "barrier" to ensure that writes before this call will never go through recovery and be applied to files that have had changes made after this call applied.

◆ waitUntilDurable()

virtual bool mongo::dur::DurableInterface::waitUntilDurable ( )
pure virtual

Wait for acknowledgement of the next group commit.

Returns
true if –dur is on. There will be delay.
false if –dur is off.

Friends And Related Function Documentation

◆ startup

void startup ( ClockSource *  cs,
int64_t  serverStartMs 
)
friend

Invoked at server startup.

Called during startup to startup the durability module.

Recovers the database by replaying journal files and then starts the durability thread.

Does nothing if storageGlobalParams.dur is false

Member Data Documentation

◆ _impl

DurableInterface* mongo::dur::DurableInterface::_impl
staticprivate

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