diff options
author | Dwight <dwight@10gen.com> | 2011-04-28 13:36:22 -0400 |
---|---|---|
committer | Dwight <dwight@10gen.com> | 2011-04-28 13:36:22 -0400 |
commit | 02048643945239f7e17795b0707481cd11f947c4 (patch) | |
tree | 31ba18cebfadfaad88908c98486bfa644723e063 | |
parent | 77f533612ca7eaa54b9c0718e18462bae541c0f9 (diff) | |
download | mongo-02048643945239f7e17795b0707481cd11f947c4.tar.gz |
fix journal recovery for case when lsn file is zero bytes long
-rw-r--r-- | db/dur_journal.cpp | 5 | ||||
-rw-r--r-- | util/file.h | 2 |
2 files changed, 7 insertions, 0 deletions
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) {} |