summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency/deferred_writer.cpp
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2017-09-06 16:15:01 -0400
committerLouis Williams <louis.williams@mongodb.com>2017-09-11 11:38:20 -0400
commit19cdcf904e81c70d6a433c76771ff445ae290dcd (patch)
tree44a2dc68c7f00041fafdf2cfbc24742b6fe8a84c /src/mongo/db/concurrency/deferred_writer.cpp
parent83242faed10c8ce6bd78e20dcfd791408d84e51a (diff)
downloadmongo-19cdcf904e81c70d6a433c76771ff445ae290dcd.tar.gz
SERVER-30831 Log dropped writes at a limited rate when dbCheck health log buffer is full
Diffstat (limited to 'src/mongo/db/concurrency/deferred_writer.cpp')
-rw-r--r--src/mongo/db/concurrency/deferred_writer.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mongo/db/concurrency/deferred_writer.cpp b/src/mongo/db/concurrency/deferred_writer.cpp
index 0ffa4a7c353..fe2551bb568 100644
--- a/src/mongo/db/concurrency/deferred_writer.cpp
+++ b/src/mongo/db/concurrency/deferred_writer.cpp
@@ -41,7 +41,7 @@
namespace mongo {
namespace {
-auto kLogInterval = stdx::chrono::hours(1);
+auto kLogInterval = stdx::chrono::minutes(1);
}
void DeferredWriter::_logFailure(const Status& status) {
@@ -51,6 +51,16 @@ void DeferredWriter::_logFailure(const Status& status) {
}
}
+void DeferredWriter::_logDroppedEntry() {
+ _droppedEntries += 1;
+ if (TimePoint::clock::now() - _lastLoggedDrop > kLogInterval) {
+ log() << "Deferred write buffer for " << _nss.toString() << " is full. " << _droppedEntries
+ << " entries have been dropped.";
+ _lastLoggedDrop = stdx::chrono::system_clock::now();
+ _droppedEntries = 0;
+ }
+}
+
Status DeferredWriter::_makeCollection(OperationContext* opCtx) {
BSONObjBuilder builder;
builder.append("create", _nss.coll());
@@ -122,6 +132,7 @@ DeferredWriter::DeferredWriter(NamespaceString nss, CollectionOptions opts, int6
_maxNumBytes(maxSize),
_nss(nss),
_numBytes(0),
+ _droppedEntries(0),
_lastLogged(TimePoint::clock::now() - kLogInterval) {}
DeferredWriter::~DeferredWriter() {}
@@ -160,6 +171,7 @@ bool DeferredWriter::insertDocument(BSONObj obj) {
if (_numBytes + obj.objsize() >= _maxNumBytes) {
// If not, drop it. We always drop new entries rather than old ones; that way the caller
// knows at the time of the call that the entry was dropped.
+ _logDroppedEntry();
return false;
}
@@ -170,4 +182,9 @@ bool DeferredWriter::insertDocument(BSONObj obj) {
return true;
}
+int64_t DeferredWriter::getDroppedEntries() {
+ return _droppedEntries;
+}
+
+
} // namespace mongo