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(); }
/** throws */ void removeJournalFiles() { log() << "removeJournalFiles" << endl; try { for ( boost::filesystem::directory_iterator i( getJournalDir() ); i != boost::filesystem::directory_iterator(); ++i ) { string fileName = boost::filesystem::path(*i).leaf(); if( str::startsWith(fileName, "j._") ) { try { boost::filesystem::remove(*i); } catch(std::exception& e) { log() << "couldn't remove " << fileName << ' ' << e.what() << endl; throw; } } } try { boost::filesystem::remove(lsnPath()); } catch(...) { log() << "couldn't remove " << lsnPath().string() << endl; throw; } } catch( std::exception& e ) { log() << "error removing journal files " << e.what() << endl; throw; } assert(!haveJournalFiles()); log(1) << "removeJournalFiles end" << endl; }
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 }