/** locking in read lock when called */ static void _go(AlignedBuilder& bb) { if( wi._writes.empty() ) return; PREPLOGBUFFER(bb); // todo: add double buffering so we can be (not even read locked) during WRITETOJOURNAL WRITETOJOURNAL(bb); // write the noted write intent entries to the data files WRITETODATAFILES(); wi.clear(); REMAPPRIVATEVIEW(); }
/** locking in read lock when called @see MongoMMF::close() */ static void groupCommit() { dbMutex.assertAtLeastReadLocked(); if( !commitJob.hasWritten() ) return; PREPLOGBUFFER(); WRITETOJOURNAL(commitJob._ab); // data is now in the journal, which is sufficient for acknowledging getlasterror. // (ok to crash after that) log() << "TEMP NOTIFYING COMMITTED" << endl; commitJob.notifyCommitted(); // write the noted write intent entries to the data files. // this has to come after writing to the journal, obviously... MongoFile::markAllWritable(); // for _DEBUG. normally we don't write in a read lock WRITETODATAFILES(); if (!dbMutex.isWriteLocked()) MongoFile::unmarkAllWritable(); commitJob.reset(); // REMAPPRIVATEVIEW // // remapping private views must occur after WRITETODATAFILES otherwise // we wouldn't see newly written data on reads. // DEV assert( !commitJob.hasWritten() ); if( !dbMutex.isWriteLocked() ) { // this needs done in a write lock thus we do it on the next acquisition of that // instead of here (there is no rush if you aren't writing anyway -- but it must happen, // if it is done, before any uncommitted writes occur). // dbMutex._remapPrivateViewRequested = true; } else { // however, if we are already write locked, we must do it now -- up the call tree someone // may do a write without a new lock acquisition. this can happen when MongoMMF::close() calls // this method when a file (and its views) is about to go away. // REMAPPRIVATEVIEW(); } }
static void remapPrivateView() { try { // REMAPPRIVATEVIEW // // remapping private views must occur after WRITETODATAFILES otherwise // we wouldn't see newly written data on reads. // invariant(!commitJob.hasWritten()); stats.curr->_commitsInWriteLock++; REMAPPRIVATEVIEW(); } catch (DBException& e) { log() << "dbexception in remapPrivateView causing immediate shutdown: " << e.toString() << endl; mongoAbort("gc1"); } catch (std::ios_base::failure& e) { log() << "ios_base exception in remapPrivateView causing immediate shutdown: " << e.what() << endl; mongoAbort("gc2"); } catch (std::bad_alloc& e) { log() << "bad_alloc exception in remapPrivateView causing immediate shutdown: " << e.what() << endl; mongoAbort("gc3"); } catch (std::exception& e) { log() << "exception in remapPrivateView causing immediate shutdown: " << e.what() << endl; mongoAbort("gc4"); } LOG(4) << "remapPrivateView end" << endl; }