void WRITETODATAFILES(const JSectHeader& h, AlignedBuilder& uncompressed) { #ifdef _WIN32 SimpleMutex::scoped_lock _globalFlushMutex(globalFlushMutex); #endif Timer t; WRITETODATAFILES_Impl1(h, uncompressed); long long m = t.micros(); stats.curr->_writeToDataFilesMicros += m; LOG(2) << "journal WRITETODATAFILES " << m / 1000.0 << "ms" << endl; }
void flush() { if (!_view || !_fd) return; LockMongoFilesShared mmfilesLock; if ( MongoFile::getAllFiles().count( _theFile ) == 0 ) { // this was deleted while we were unlocked return; } SimpleMutex::scoped_lock _globalFlushMutex(globalFlushMutex); scoped_lock lk(*_flushMutex); int loopCount = 0; bool success = false; bool timeout = false; int dosError = ERROR_SUCCESS; const int maximumTimeInSeconds = 60 * 15; Timer t; while ( !success && !timeout ) { ++loopCount; success = FALSE != FlushViewOfFile( _view, 0 ); if ( !success ) { dosError = GetLastError(); if ( dosError != ERROR_LOCK_VIOLATION ) { break; } timeout = t.seconds() > maximumTimeInSeconds; } } if ( success && loopCount > 1 ) { log() << "FlushViewOfFile for " << _filename << " succeeded after " << loopCount << " attempts taking " << t.millis() << "ms" << endl; } else if ( !success ) { log() << "FlushViewOfFile for " << _filename << " failed with error " << dosError << " after " << loopCount << " attempts taking " << t.millis() << "ms" << endl; // Abort here to avoid data corruption fassert(16387, false); } success = FALSE != FlushFileBuffers(_fd); if (!success) { int err = GetLastError(); out() << "FlushFileBuffers failed: " << errnoWithDescription( err ) << " file: " << _filename << endl; dataSyncFailedHandler(); } }
void flush() { if (!_view || !_fd) return; SimpleMutex::scoped_lock _globalFlushMutex(globalFlushMutex); scoped_lock lk(*_flushMutex); int loopCount = 0; bool success = false; bool timeout = false; int dosError = ERROR_SUCCESS; const int maximumTimeInSeconds = 60 * 15; Timer t; while ( !success && !timeout ) { ++loopCount; success = FALSE != FlushViewOfFile( _view, 0 ); if ( !success ) { dosError = GetLastError(); if ( dosError != ERROR_LOCK_VIOLATION ) { break; } timeout = t.seconds() > maximumTimeInSeconds; } } if ( success && loopCount > 1 ) { log() << "FlushViewOfFile for " << _filename << " succeeded after " << loopCount << " attempts taking " << t.millis() << "ms" << endl; } else if ( !success ) { log() << "FlushViewOfFile for " << _filename << " failed with error " << dosError << " after " << loopCount << " attempts taking " << t.millis() << "ms" << endl; // Abort here to avoid data corruption fassert(16387, false); } success = FALSE != FlushFileBuffers(_fd); if (!success) { int err = GetLastError(); out() << "FlushFileBuffers failed " << err << " file: " << _filename << endl; } }