![]() |
Storage Engine API
|
Classes | |
class | Already |
Bitmap to remember things we have already marked for journaling. More... | |
class | BufferGuard |
Used inside the journal writer thread to ensure that used buffers are cleaned up properly. More... | |
class | BufReaderUnitTest |
struct | BufReaderY |
class | CommitJob |
Tracks all write operations on the private view so they can be journaled. More... | |
class | DropDbOp |
record drop of a database More... | |
class | DurableInterface |
class | DurOp |
DurOp - Operations we journal that aren't just basic writes. More... | |
class | FileCreatedOp |
indicates creation of a new file More... | |
struct | JDbContext |
declares "the next entry(s) are for this database / file path prefix" More... | |
struct | JEntry |
an individual write operation within a group commit section. More... | |
struct | JHeader |
beginning header for a journal/j._<n> file there is nothing important int this header at this time. More... | |
class | Journal |
the writeahead journal for durability More... | |
class | JournalSectionIterator |
read through the memory mapped data of a journal file (journal/j._<n> file) throws More... | |
class | JournalWriter |
Manages the thread and queues used for writing the journal to disk and notify parties with are waiting on the write concern. More... | |
struct | JSectFooter |
group commit section footer. More... | |
struct | JSectHeader |
"Section" header. More... | |
struct | LSNFile |
"last sequence number" More... | |
struct | ParsedJournalEntry |
class | RecoveryJob |
call go() to execute a recovery from existing journal files. More... | |
struct | Stats |
journaling stats. More... | |
struct | WriteIntent |
Declaration of an intent to write to a region of a memory mapped view. More... | |
Typedefs | |
typedef std::vector< std::shared_ptr< DurOp > > | DurOpsVector |
typedef std::vector< WriteIntent > | WriteIntentsVector |
Functions | |
void | PREPLOGBUFFER (JSectHeader &outHeader, AlignedBuilder &outBuffer, ClockSource *cs, int64_t serverStartMs) |
boost::filesystem::path | getJournalDir () |
void | preallocateFiles () |
static void | durThread (ClockSource *cs, int64_t serverStartMs) |
The main durability thread loop. More... | |
static void | remapPrivateView (OperationContext *opCtx, double fraction) |
Remaps the private view from the shared view so that it does not consume too much copy-on-write/swap space. More... | |
void | startup (ClockSource *cs, int64_t serverStartMs) |
Invoked at server startup. More... | |
void | setJournalListener (JournalListener *jl) |
JournalListener * | getJournalListener () |
MONGO_INITIALIZER() | InitializeJournalingParams (InitializerContext *context) |
MONGO_STATIC_ASSERT (sizeof(Checksum)==16) | |
MONGO_STATIC_ASSERT (sizeof(JHeader)==8192) | |
MONGO_STATIC_ASSERT (sizeof(JSectHeader)==20) | |
MONGO_STATIC_ASSERT (sizeof(JSectFooter)==32) | |
MONGO_STATIC_ASSERT (sizeof(JEntry)==12) | |
MONGO_STATIC_ASSERT (sizeof(LSNFile)==88) | |
void | removeOldJournalFile (boost::filesystem::path p) |
boost::filesystem::path | lsnPath () |
void | journalingFailure (const char *msg) |
this should be called when something really bad happens so that we can flag appropriately More... | |
bool | haveJournalFiles (bool anyFiles) |
never throws More... | |
void | removeJournalFiles () |
throws More... | |
void | journalCleanup (bool log=false) |
at termination after db files closed & fsynced also after recovery closes and removes journal files More... | |
bool | _preallocateIsFaster () |
bool | preallocateIsFaster () |
void | preallocateFile (boost::filesystem::path p, unsigned long long len) |
boost::filesystem::path | preallocPath (int n) |
void | _preallocateFiles () |
void | checkFreeSpace () |
boost::filesystem::path | findPrealloced () |
void | journalMakeDir (ClockSource *cs, int64_t serverStartMs) |
assure journal/ dir exists. More... | |
unsigned long long | journalReadLSN () |
called during recovery (the error message text below assumes that) More... | |
uint64_t | generateNextSeqNumber (ClockSource *cs, int64_t serverStartMs) |
Generates the next sequence number for use in the journal, guaranteed to be greater than all prior sequence numbers. More... | |
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 () |
void | WRITETOJOURNAL (const JSectHeader &h, const AlignedBuilder &uncompressed) |
write (append) the buffer we have built to the journal and fsync it. More... | |
static DurableMappedFile * | findMMF_inlock (void *ptr, size_t &ofs) |
static void | prepBasicWrite_inlock (AlignedBuilder &bb, const WriteIntent *i, RelativePath &lastDbPath) |
put the basic write operation into the buffer (bb) to be journaled More... | |
static void | prepBasicWrites (AlignedBuilder &bb, const std::vector< WriteIntent > &intents) |
basic write ops / write intents. More... | |
static void | _PREPLOGBUFFER (JSectHeader &h, AlignedBuilder &bb, ClockSource *cs, int64_t serverStartMs) |
we will build an output buffer ourself and then use O_DIRECT we could be in read lock for this caller handles locking More... | |
static void | getFiles (boost::filesystem::path dir, vector< boost::filesystem::path > &files) |
Get journal filenames, in order. More... | |
static string | fileName (const char *dbName, int fileNo) |
void | _recover (OperationContext *opCtx) |
void | replayJournalFilesAtStartup () |
recover from a crash called during startup throws on error More... | |
Variables | |
Stats | stats |
CommitJob | commitJob |
DurableInterface *DurableInterface::_impl & | nonDurableImpl |
const unsigned | UncommittedBytesLimit = (sizeof(void*) == 4) ? 50 * 1024 * 1024 : 512 * 1024 * 1024 |
unsigned long long | DataLimitPerJournalFile |
bool | usingPreallocate = false |
Journal | j |
const unsigned long long | LsnShutdownSentinel = ~((unsigned long long)0) |
bool | okToCleanUp = false |
at clean shutdown More... | |
const int | NUM_PREALLOC_FILES = 3 |
const long long | ExtraKeepTimeMs = 10000 |
const unsigned | Alignment = 8192 |
const RelativePath | local = RelativePath::fromRelativePath("local") |
mongo::dur::BufReaderUnitTest | brunittest |
typedef std::vector<std::shared_ptr<DurOp> > mongo::dur::DurOpsVector |
typedef std::vector<WriteIntent> mongo::dur::WriteIntentsVector |
void mongo::dur::_preallocateFiles | ( | ) |
bool mongo::dur::_preallocateIsFaster | ( | ) |
|
static |
we will build an output buffer ourself and then use O_DIRECT we could be in read lock for this caller handles locking
void mongo::dur::_recover | ( | OperationContext * | opCtx | ) |
void mongo::dur::checkFreeSpace | ( | ) |
|
static |
The main durability thread loop.
There is a single instance of this function running.
|
static |
|
static |
boost::filesystem::path mongo::dur::findPrealloced | ( | ) |
uint64_t mongo::dur::generateNextSeqNumber | ( | ClockSource * | cs, |
int64_t | serverStartMs | ||
) |
Generates the next sequence number for use in the journal, guaranteed to be greater than all prior sequence numbers.
|
static |
Get journal filenames, in order.
Throws if unexpected content found.
boost::filesystem::path mongo::dur::getJournalDir | ( | ) |
JournalListener * mongo::dur::getJournalListener | ( | ) |
bool mongo::dur::haveJournalFiles | ( | bool | anyFiles | ) |
never throws
never throws.
anyFiles | by default we only look at j._* files. If anyFiles is true, return true if there are any files in the journal directory. checkForUncleanShutdown() uses this to make sure that the journal directory is mounted. |
anyFiles | by default we only look at j._* files. If anyFiles is true, return true if there are any files in the journal directory. checkForUncleanShutdown() uses this to make sure that the journal directory is mounted. |
MONGO_INITIALIZER() mongo::dur::InitializeJournalingParams | ( | InitializerContext * | context | ) |
void mongo::dur::journalCleanup | ( | bool | log = false | ) |
at termination after db files closed & fsynced also after recovery closes and removes journal files
log | report in log that we are cleaning up if we actually do any work |
void mongo::dur::journalingFailure | ( | const char * | msg | ) |
this should be called when something really bad happens so that we can flag appropriately
flag that something has gone wrong during writing to the journal (not for recovery mode)
todo: (1) don't log too much (2) make an indicator in the journal dir that something bad happened. (2b) refuse to do a recovery startup if that is there without manual override.
void mongo::dur::journalMakeDir | ( | ClockSource * | cs, |
int64_t | serverStartMs | ||
) |
assure journal/ dir exists.
throws. call during startup.
throws
unsigned long long mongo::dur::journalReadLSN | ( | ) |
called during recovery (the error message text below assumes that)
read lsn from disk from the last run before doing recovery
boost::filesystem::path mongo::dur::lsnPath | ( | ) |
mongo::dur::MONGO_STATIC_ASSERT | ( | sizeof(Checksum) | = =16 | ) |
mongo::dur::MONGO_STATIC_ASSERT | ( | sizeof(JHeader) | = =8192 | ) |
mongo::dur::MONGO_STATIC_ASSERT | ( | sizeof(JSectHeader) | = =20 | ) |
mongo::dur::MONGO_STATIC_ASSERT | ( | sizeof(JSectFooter) | = =32 | ) |
mongo::dur::MONGO_STATIC_ASSERT | ( | sizeof(JEntry) | = =12 | ) |
mongo::dur::MONGO_STATIC_ASSERT | ( | sizeof(LSNFile) | = =88 | ) |
void mongo::dur::notifyPostDataFileFlush | ( | ) |
void mongo::dur::notifyPreDataFileFlush | ( | ) |
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.
void mongo::dur::preallocateFile | ( | boost::filesystem::path | p, |
unsigned long long | len | ||
) |
void mongo::dur::preallocateFiles | ( | ) |
bool mongo::dur::preallocateIsFaster | ( | ) |
|
inline |
|
static |
put the basic write operation into the buffer (bb) to be journaled
|
static |
basic write ops / write intents.
note there is no particular order to these : if we have two writes to the same location during the group commit interval, it is likely (although not assured) that it is journaled here once.
void mongo::dur::PREPLOGBUFFER | ( | JSectHeader & | outHeader, |
AlignedBuilder & | outBuffer, | ||
ClockSource * | cs, | ||
int64_t | serverStartMs | ||
) |
|
static |
Remaps the private view from the shared view so that it does not consume too much copy-on-write/swap space.
Must only be called after the in-memory journal has been flushed to disk and applied on top of the shared view.
fraction | Value between (0, 1] indicating what fraction of the memory to remap. Remapping too much or too frequently incurs copy-on-write page fault cost. |
void mongo::dur::removeJournalFiles | ( | ) |
throws
void mongo::dur::removeOldJournalFile | ( | boost::filesystem::path | p | ) |
void mongo::dur::replayJournalFilesAtStartup | ( | ) |
recover from a crash called during startup throws on error
void mongo::dur::setJournalListener | ( | JournalListener * | jl | ) |
void mongo::dur::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.
void mongo::dur::startup | ( | ClockSource * | cs, |
int64_t | serverStartMs | ||
) |
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
void mongo::dur::WRITETOJOURNAL | ( | const JSectHeader & | h, |
const AlignedBuilder & | uncompressed | ||
) |
write (append) the buffer we have built to the journal and fsync it.
Writes the specified uncompressed buffer to the journal.
outside of dbMutex lock as this could be slow.
uncompressed | - a buffer that will be written to the journal after compression will not return until on disk |
const unsigned mongo::dur::Alignment = 8192 |
mongo::dur::BufReaderUnitTest mongo::dur::brunittest |
CommitJob mongo::dur::commitJob |
unsigned long long mongo::dur::DataLimitPerJournalFile |
const long long mongo::dur::ExtraKeepTimeMs = 10000 |
Journal mongo::dur::j |
const RelativePath mongo::dur::local = RelativePath::fromRelativePath("local") |
const unsigned long long mongo::dur::LsnShutdownSentinel = ~((unsigned long long)0) |
DurableInterface* DurableInterface::_impl& mongo::dur::nonDurableImpl |
const int mongo::dur::NUM_PREALLOC_FILES = 3 |
bool mongo::dur::okToCleanUp = false |
at clean shutdown
true if ok to cleanup journal files at termination.
otherwise, files journal will be retained.
Stats mongo::dur::stats |
const unsigned mongo::dur::UncommittedBytesLimit = (sizeof(void*) == 4) ? 50 * 1024 * 1024 : 512 * 1024 * 1024 |
bool mongo::dur::usingPreallocate = false |