From a076624f2eda0f537987a4eee461bae1060cffca Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Thu, 16 Dec 2010 17:15:50 -0500 Subject: [PATCH] force commit every 100MB --- db/dur.cpp | 11 ++++++++++- db/dur_commitjob.cpp | 1 + db/dur_commitjob.h | 8 ++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/db/dur.cpp b/db/dur.cpp index f8ae4f597f0..d0d128ea910 100644 --- a/db/dur.cpp +++ b/db/dur.cpp @@ -515,9 +515,18 @@ namespace mongo { void unlinkThread(); void recover(); void releasingWriteLock() { + try { #if defined(_DEBUG) - getDur().debugCheckLastDeclaredWrite(); + getDur().debugCheckLastDeclaredWrite(); #endif + + if (commitJob.bytes() > 100*1024*1024) + groupCommit(); + } + catch(std::exception& e) { + log() << "exception in dur::releasingWriteLock causing immediate shutdown: " << e.what() << endl; + abort(); // based on myTerminate() + } } /** at startup, recover, and then start the journal threads */ diff --git a/db/dur_commitjob.cpp b/db/dur_commitjob.cpp index 6a1fcdc081d..049ee41c3fa 100644 --- a/db/dur_commitjob.cpp +++ b/db/dur_commitjob.cpp @@ -43,6 +43,7 @@ namespace mongo { _hasWritten = false; _wi.clear(); _ab.reset(); + _bytes = 0; } } } diff --git a/db/dur_commitjob.h b/db/dur_commitjob.h index ee415ba609e..e265f7121b4 100644 --- a/db/dur_commitjob.h +++ b/db/dur_commitjob.h @@ -89,7 +89,7 @@ namespace mongo { public: AlignedBuilder _ab; // for direct i/o writes to journal - CommitJob() : _ab(4 * 1024 * 1024) , _hasWritten(false) { } + CommitJob() : _ab(4 * 1024 * 1024) , _hasWritten(false), _bytes(0) { } /** record/note an intent to write */ void note(WriteIntent& w); @@ -117,10 +117,13 @@ namespace mongo { _notify.wait(); } + size_t bytes() const { return _bytes; } + private: bool _hasWritten; Writes _wi; NotifyAll _notify; + size_t _bytes; }; extern CommitJob commitJob; @@ -170,8 +173,9 @@ namespace mongo { // remember intent. we will journal it in a bit _wi._writes.push_back(w); + _bytes += w.len; wassert( _wi._writes.size() < 2000000 ); - assert( _wi._writes.size() < 20000000 ); + //assert( _wi._writes.size() < 20000000 ); } } }