Permalink
Browse files

dur once prealloc is used keep using it

  • Loading branch information...
1 parent 71ef504 commit 221dddb522ca05c2b875590ad3c9188d9cb42ab6 @dwight dwight committed Feb 6, 2011
Showing with 12 additions and 11 deletions.
  1. +12 −11 db/dur_journal.cpp
View
@@ -47,7 +47,7 @@ namespace mongo {
BOOST_STATIC_ASSERT( sizeof(JEntry) == 12 );
BOOST_STATIC_ASSERT( sizeof(LSNFile) == 88 );
- bool _preallocateIsFaster = false;
+ bool usingPreallocate = false;
void removeOldJournalFile(path p);
@@ -248,20 +248,21 @@ namespace mongo {
}
void preallocateFiles() {
- _preallocateIsFaster = preallocateIsFaster();
- if( !_preallocateIsFaster )
- return;
-
- try {
- _preallocateFiles();
- }
- catch(...) {
- log() << "warning caught exception in preallocateFiles, continuing" << endl;
+ if( preallocateIsFaster() ||
+ exists(getJournalDir()/"prealloc.0") || // if enabled previously, keep using
+ exists(getJournalDir()/"prealloc.1") ) {
+ usingPreallocate = true;
+ try {
+ _preallocateFiles();
+ }
+ catch(...) {
+ log() << "warning caught exception in preallocateFiles, continuing" << endl;
+ }
}
}
void removeOldJournalFile(path p) {
- if( _preallocateIsFaster ) {
+ if( usingPreallocate ) {
try {
for( int i = 0; i <= 2; i++ ) {
string fn = str::stream() << "prealloc." << i;

0 comments on commit 221dddb

Please sign in to comment.