diff --git a/db/dur.cpp b/db/dur.cpp index 9cf79ac80c3..916668f3f69 100644 --- a/db/dur.cpp +++ b/db/dur.cpp @@ -193,6 +193,11 @@ namespace mongo { return p; } + void DurableImpl::commitIfNeeded() { + if (commitJob.bytes() > 50*1024*1024) // should this also fire if CmdLine::DurAlwaysCommit? + groupCommit(); + } + /** Used in _DEBUG builds to check that we didn't overwrite the last intent that was declared. called just before writelock release. we check a few bytes after the declared region to see if they changed. diff --git a/db/dur.h b/db/dur.h index 5b666b39bcc..bc6350d82a7 100644 --- a/db/dur.h +++ b/db/dur.h @@ -75,6 +75,15 @@ namespace mongo { */ virtual bool commitNow() = 0; + /** Commit if enough bytes have been modified. Current threshold is 50MB + + The idea is that long running write operations that dont yield + (like creating an index or update with $atomic) can call this + whenever the db is in a sane state and it will prevent commits + from growing too large. + */ + virtual void commitIfNeeded() = 0; + #if defined(_DEBUG) virtual void debugCheckLastDeclaredWrite() = 0; #endif @@ -145,6 +154,7 @@ namespace mongo { void droppingDb(string db) { } bool awaitCommit() { return false; } bool commitNow() { return false; } + void commitIfNeeded() { } #if defined(_DEBUG) void debugCheckLastDeclaredWrite() {} #endif @@ -159,6 +169,7 @@ namespace mongo { void droppingDb(string db); bool awaitCommit(); bool commitNow(); + void commitIfNeeded(); #if defined(_DEBUG) void debugCheckLastDeclaredWrite(); #endif