void DurableImpl::commitAndStopDurThread() { CommitNotifier::When when = commitNotify.now(); // There is always just one waiting anyways flushRequested.notify_one(); // commitNotify.waitFor ensures that whatever was scheduled for journaling before this // call has been persisted to the journal file. This does not mean that this data has been // applied to the shared view yet though, that's why we wait for applyToDataFilesNotify. applyToDataFilesNotify.waitFor(when); // Flush the shared view to disk. MongoFile::flushAll(true); // Once the shared view has been flushed, we do not need the journal files anymore. journalCleanup(true); // Double check post-conditions invariant(!haveJournalFiles()); shutdownRequested.store(1); // Wait for the durability thread to terminate log() << "Terminating durability thread ..."; _durThreadHandle.join(); }
void DurableImpl::syncDataAndTruncateJournal(OperationContext* txn) { invariant(txn->lockState()->isW()); // Once this returns, all the outstanding journal has been applied to the data files and // so it's safe to do the flushAll/journalCleanup below. commitNow(txn); // Flush the shared view to disk. MongoFile::flushAll(true); // Once the shared view has been flushed, we do not need the journal files anymore. journalCleanup(true); // Double check post-conditions invariant(!haveJournalFiles()); }
void DurableImpl::syncDataAndTruncateJournal(OperationContext* txn) { invariant(txn->lockState()->isW()); // a commit from the commit thread won't begin while we are in the write lock, // but it may already be in progress and the end of that work is done outside // (dbMutex) locks. This line waits for that to complete if already underway. { SimpleMutex::scoped_lock lk(commitJob.groupCommitMutex); } commitNow(txn); MongoFile::flushAll(true); journalCleanup(); invariant(!haveJournalFiles()); // Double check post-conditions }