Exemplo n.º 1
0
        /** called during recovery (the error message text below assumes that)
        */
        unsigned long long journalReadLSN() {
            if( !debug ) {
                // in nondebug build, for now, be conservative until more tests written, and apply the whole journal.
                // however we will still write the lsn file to exercise that code, and use in _DEBUG build.
                return 0;
            }

            if( !MemoryMappedFile::exists(lsnPath()) ) {
                log() << "info no lsn file in journal/ directory" << endl;
                return 0;
            }

            try {
                // os can flush as it likes.  if it flushes slowly, we will just do extra work on recovery.
                // however, given we actually close the file when writing, that seems unlikely.
                LSNFile L;
                File f;
                f.open(lsnPath().string().c_str());
                assert(f.is_open());
                f.read(0,(char*)&L, sizeof(L));
                unsigned long long lsn = L.get();
                return lsn;
            }
            catch(std::exception& e) {
                uasserted(13611, str::stream() << "can't read lsn file in journal directory : " << e.what());
            }
            return 0;
        }
Exemplo n.º 2
0
 /** remember "last sequence number" to speed recoveries
     concurrency: called by durThread only.
 */
 void Journal::updateLSNFile() {
     if( !_writeToLSNNeeded )
         return;
     durThreadMain.assertWithin();
     _writeToLSNNeeded = false;
     try {
         // os can flush as it likes.  if it flushes slowly, we will just do extra work on recovery.
         // however, given we actually close the file, that seems unlikely.
         File f;
         f.open(lsnPath().string().c_str());
         if( !f.is_open() ) { 
             // can get 0 if an i/o error
             log() << "warning: open of lsn file failed" << endl;
             return;
         }
         log() << "lsn set " << _lastFlushTime << endl;
         LSNFile lsnf;
         lsnf.set(_lastFlushTime);
         f.write(0, (char*)&lsnf, sizeof(lsnf));
     }
     catch(std::exception& e) {
         log() << "warning: write to lsn file failed " << e.what() << endl;
         // keep running (ignore the error). recovery will be slow.
     }
 }
Exemplo n.º 3
0
        /** called during recovery (the error message text below assumes that)
        */
        unsigned long long journalReadLSN() {
            if( !exists(lsnPath()) ) {
                log() << "info no lsn file in journal/ directory" << endl;
                return 0;
            }

            try {
                // os can flush as it likes.  if it flushes slowly, we will just do extra work on recovery.
                // however, given we actually close the file when writing, that seems unlikely.
                LSNFile L;
                File f;
                f.open(lsnPath().string().c_str());
                assert(f.is_open());
                if( f.len() == 0 ) { 
                    // this could be 'normal' if we crashed at the right moment
                    log() << "info lsn file is zero bytes long" << endl;
                    return 0;
                }
                f.read(0,(char*)&L, sizeof(L));
                unsigned long long lsn = L.get();
                return lsn;
            }
            catch(std::exception& e) {
                uasserted(13611, str::stream() << "can't read lsn file in journal directory : " << e.what());
            }
            return 0;
        }