Permalink
Browse files

Move call to syncDataAndTruncateJournal higher in repair SERVER-5393

Previously we could have exited with the journal reffering to files that
had been deleted. By truncating the journal earlier we can avoid that.
The call to flushAll was also moved to make intent clearer to future
maintainers.
  • Loading branch information...
1 parent 9700745 commit ca02fab3d15f1075235cf80d271e8a2c77bf1217 @RedBeard0531 RedBeard0531 committed May 30, 2012
Showing with 3 additions and 6 deletions.
  1. +3 −6 src/mongo/db/pdfile.cpp
View
@@ -1791,20 +1791,19 @@ namespace mongo {
Database::closeDatabase( dbName, reservedPathString.c_str() );
}
+ getDur().syncDataAndTruncateJournal(); // Must be done before and after repair
+ MongoFile::flushAll(true); // need both in case journaling is disabled
+
if ( !res ) {
errmsg = str::stream() << "clone failed for " << dbName << " with error: " << errmsg;
problem() << errmsg << endl;
if ( !preserveClonedFilesOnFailure )
MONGO_ASSERT_ON_EXCEPTION( boost::filesystem::remove_all( reservedPath ) );
- getDur().syncDataAndTruncateJournal(); // Must be done before and after repair
-
return false;
}
- MongoFile::flushAll(true);
-
Client::Context ctx( dbName );
Database::closeDatabase( dbName, dbpath );
@@ -1821,8 +1820,6 @@ namespace mongo {
if ( !backupOriginalFiles )
MONGO_ASSERT_ON_EXCEPTION( boost::filesystem::remove_all( reservedPath ) );
- getDur().syncDataAndTruncateJournal(); // Must be done before and after repair
-
return true;
}

0 comments on commit ca02fab

Please sign in to comment.