Storage Engine API
mongo::dur::Journal Class Reference

the writeahead journal for durability More...

#include <dur_journalimpl.h>

Detailed Description

the writeahead journal for durability

Classes

struct  JFile
 

Public Member Functions

 Journal ()
 
void init (ClockSource *cs, int64_t serverStartMs)
 call during startup by journalMakeDir() More...
 
void rotate ()
 check if time to rotate files. More...
 
void journal (const JSectHeader &h, const AlignedBuilder &b)
 append to the journal file More...
 
boost::filesystem::path getFilePathFor (int filenumber) const
 
void cleanup (bool log)
 
unsigned long long curFileId () const
 
void assureLogFileOpen ()
 
void open ()
 open a journal file to journal operations to. More...
 

Public Attributes

std::string dir
 

Private Member Functions

void _rotate (unsigned long long lsnOfCurrentJournalEntry)
 check if time to rotate files. More...
 
void _open ()
 
void closeCurrentJournalFile ()
 
void removeUnneededJournalFiles ()
 remove older journal files. More...
 
void updateLSNFile (unsigned long long lsnOfCurrentJournalEntry)
 remember "last sequence number" to speed recoveries concurrency: called by durThread only. More...
 

Private Attributes

unsigned long long _written = 0
 
unsigned _nextFileNumber = 0
 
SimpleMutex _curLogFileMutex
 
LogFile_curLogFile
 
unsigned long long _curFileId
 
std::list< JFile_oldJournalFiles
 
AtomicUInt64 _lastSeqNumberWrittenToSharedView
 
AtomicUInt64 _preFlushTime
 
AtomicUInt64 _lastFlushTime
 
AtomicWord< bool > _writeToLSNNeeded
 
ClockSource * _clock
 
int64_t _serverStartMs
 

Friends

void setLastSeqNumberWrittenToSharedView (uint64_t seqNumber)
 Informs the journaling system that all writes on or before the passed in sequence number have been written to the data files' shared mmap view. More...
 
void notifyPreDataFileFlush ()
 Call these before (pre) and after (post) the datafiles are flushed to disk by the DataFileSync thread. More...
 
void notifyPostDataFileFlush ()
 

Constructor & Destructor Documentation

◆ Journal()

mongo::dur::Journal::Journal ( )

Member Function Documentation

◆ _open()

void mongo::dur::Journal::_open ( )
private

◆ _rotate()

void mongo::dur::Journal::_rotate ( unsigned long long  lsnOfCurrentJournalEntry)
private

check if time to rotate files.

assure a file is open. internally called with every commit

◆ assureLogFileOpen()

void mongo::dur::Journal::assureLogFileOpen ( )
inline

◆ cleanup()

void mongo::dur::Journal::cleanup ( bool  log)

◆ closeCurrentJournalFile()

void mongo::dur::Journal::closeCurrentJournalFile ( )
private

◆ curFileId()

unsigned long long mongo::dur::Journal::curFileId ( ) const
inline

◆ getFilePathFor()

boost::filesystem::path mongo::dur::Journal::getFilePathFor ( int  filenumber) const

◆ init()

void mongo::dur::Journal::init ( ClockSource *  cs,
int64_t  serverStartMs 
)

call during startup by journalMakeDir()

◆ journal()

void mongo::dur::Journal::journal ( const JSectHeader h,
const AlignedBuilder b 
)

append to the journal file

◆ open()

void mongo::dur::Journal::open ( )

open a journal file to journal operations to.

◆ removeUnneededJournalFiles()

void mongo::dur::Journal::removeUnneededJournalFiles ( )
private

remove older journal files.

be in _curLogFileMutex but not dbMutex when calling

◆ rotate()

void mongo::dur::Journal::rotate ( )

check if time to rotate files.

assure a file is open. done separately from the journal() call as we can do this part outside of lock. thread: durThread()

◆ updateLSNFile()

void mongo::dur::Journal::updateLSNFile ( unsigned long long  lsnOfCurrentJournalEntry)
private

remember "last sequence number" to speed recoveries concurrency: called by durThread only.

Friends And Related Function Documentation

◆ notifyPostDataFileFlush

void notifyPostDataFileFlush ( )
friend

◆ notifyPreDataFileFlush

void notifyPreDataFileFlush ( )
friend

Call these before (pre) and after (post) the datafiles are flushed to disk by the DataFileSync thread.

These should not be called for any other flushes.

◆ setLastSeqNumberWrittenToSharedView

void setLastSeqNumberWrittenToSharedView ( uint64_t  seqNumber)
friend

Informs the journaling system that all writes on or before the passed in sequence number have been written to the data files' shared mmap view.

Member Data Documentation

◆ _clock

ClockSource* mongo::dur::Journal::_clock
private

◆ _curFileId

unsigned long long mongo::dur::Journal::_curFileId
private

◆ _curLogFile

LogFile* mongo::dur::Journal::_curLogFile
private

◆ _curLogFileMutex

SimpleMutex mongo::dur::Journal::_curLogFileMutex
private

◆ _lastFlushTime

AtomicUInt64 mongo::dur::Journal::_lastFlushTime
private

◆ _lastSeqNumberWrittenToSharedView

AtomicUInt64 mongo::dur::Journal::_lastSeqNumberWrittenToSharedView
private

◆ _nextFileNumber

unsigned mongo::dur::Journal::_nextFileNumber = 0
private

◆ _oldJournalFiles

std::list<JFile> mongo::dur::Journal::_oldJournalFiles
private

◆ _preFlushTime

AtomicUInt64 mongo::dur::Journal::_preFlushTime
private

◆ _serverStartMs

int64_t mongo::dur::Journal::_serverStartMs
private

◆ _writeToLSNNeeded

AtomicWord<bool> mongo::dur::Journal::_writeToLSNNeeded
private

◆ _written

unsigned long long mongo::dur::Journal::_written = 0
private

◆ dir

std::string mongo::dur::Journal::dir

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