0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

force commit every 100MB

This commit is contained in:
Mathias Stearn 2010-12-16 17:15:50 -05:00
parent 7740e42328
commit a076624f2e
3 changed files with 17 additions and 3 deletions

View File

@ -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 */

View File

@ -43,6 +43,7 @@ namespace mongo {
_hasWritten = false;
_wi.clear();
_ab.reset();
_bytes = 0;
}
}
}

View File

@ -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 );
}
}
}