diff options
Diffstat (limited to 'src/mongo/db/storage/mmap_v1/dur_commitjob.cpp')
-rw-r--r-- | src/mongo/db/storage/mmap_v1/dur_commitjob.cpp | 107 |
1 files changed, 50 insertions, 57 deletions
diff --git a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp index 27e7681b17c..aff01c1c7bf 100644 --- a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp @@ -44,83 +44,76 @@ namespace mongo { - using std::shared_ptr; - using std::endl; - using std::max; - using std::min; +using std::shared_ptr; +using std::endl; +using std::max; +using std::min; namespace dur { - void WriteIntent::absorb(const WriteIntent& other) { - dassert(overlaps(other)); +void WriteIntent::absorb(const WriteIntent& other) { + dassert(overlaps(other)); - void* newStart = min(start(), other.start()); - p = max(p, other.p); - len = (char*)p - (char*)newStart; + void* newStart = min(start(), other.start()); + p = max(p, other.p); + len = (char*)p - (char*)newStart; - dassert(contains(other)); - } + dassert(contains(other)); +} - CommitJob::CommitJob() : - _hasWritten(false), - _lastNotedPos(0), - _bytes(0) { +CommitJob::CommitJob() : _hasWritten(false), _lastNotedPos(0), _bytes(0) {} - } +CommitJob::~CommitJob() {} - CommitJob::~CommitJob() { +void CommitJob::noteOp(shared_ptr<DurOp> p) { + stdx::lock_guard<SimpleMutex> lk(groupCommitMutex); + _hasWritten = true; + _durOps.push_back(p); +} - } - - void CommitJob::noteOp(shared_ptr<DurOp> p) { - stdx::lock_guard<SimpleMutex> lk(groupCommitMutex); - _hasWritten = true; - _durOps.push_back(p); - } +void CommitJob::note(void* p, int len) { + _hasWritten = true; - void CommitJob::note(void* p, int len) { - _hasWritten = true; + if (!_alreadyNoted.checkAndSet(p, len)) { + // Remember intent. We will journal it in a bit. + _insertWriteIntent(p, len); - if (!_alreadyNoted.checkAndSet(p, len)) { - // Remember intent. We will journal it in a bit. - _insertWriteIntent(p, len); + // Round off to page address (4KB). + const size_t x = ((size_t)p) & ~0xfff; - // Round off to page address (4KB). - const size_t x = ((size_t)p) & ~0xfff; + if (x != _lastNotedPos) { + _lastNotedPos = x; - if (x != _lastNotedPos) { - _lastNotedPos = x; + // Add the full page amount + _bytes += (len + 4095) & ~0xfff; - // Add the full page amount - _bytes += (len + 4095) & ~0xfff; + if (_bytes > UncommittedBytesLimit * 3) { + _complains++; - if (_bytes > UncommittedBytesLimit * 3) { - _complains++; + // Throttle logging + if (_complains < 100 || (curTimeMillis64() - _lastComplainMs >= 60000)) { + _lastComplainMs = curTimeMillis64(); - // Throttle logging - if (_complains < 100 || (curTimeMillis64() - _lastComplainMs >= 60000)) { - _lastComplainMs = curTimeMillis64(); + warning() << "DR102 too much data written uncommitted (" << _bytes / 1000000.0 + << "MB)"; - warning() << "DR102 too much data written uncommitted (" - << _bytes / 1000000.0 << "MB)"; - - if (_complains < 10 || _complains % 10 == 0) { - printStackTrace(); - } + if (_complains < 10 || _complains % 10 == 0) { + printStackTrace(); } } } } } - - void CommitJob::committingReset() { - _hasWritten = false; - _alreadyNoted.clear(); - _intents.clear(); - _durOps.clear(); - _bytes = 0; - } - -} // namespace "dur" -} // namespace "mongo" +} + +void CommitJob::committingReset() { + _hasWritten = false; + _alreadyNoted.clear(); + _intents.clear(); + _durOps.clear(); + _bytes = 0; +} + +} // namespace "dur" +} // namespace "mongo" |