From 02048643945239f7e17795b0707481cd11f947c4 Mon Sep 17 00:00:00 2001 From: Dwight Date: Thu, 28 Apr 2011 13:36:22 -0400 Subject: fix journal recovery for case when lsn file is zero bytes long --- db/dur_journal.cpp | 5 +++++ util/file.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/db/dur_journal.cpp b/db/dur_journal.cpp index 1738884006c..b8c259a6763 100644 --- a/db/dur_journal.cpp +++ b/db/dur_journal.cpp @@ -486,6 +486,11 @@ namespace mongo { 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; diff --git a/util/file.h b/util/file.h index aed5d52fdaa..8ef58968ea6 100644 --- a/util/file.h +++ b/util/file.h @@ -38,6 +38,8 @@ namespace mongo { typedef boost::uint64_t fileofs; #endif + /* NOTE: not thread-safe. (at least the windows implementation isn't. */ + class FileInterface { public: void open(const char *fn) {} -- cgit v1.2.1