From 42add01ac7ba93413784de93fa9b64c1afa0e2a8 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 5 Jun 2019 13:25:32 -0400 Subject: [PATCH] rgw/OutputDataSocket: actually discard data on full buffer A dout message in OutputDataSocket::append_output() states that data will be dropped when appending would cause data_max_backlog to be exceeded--but the method appends it anyway. Log output discards at level 0, as messages will be lost. Suppress repeated warnings mod 100. Switch to vector. Fixes: http://tracker.ceph.com/issues/40178 Signed-off-by: Matt Benjamin (cherry picked from commit c806b825dae649829de8847d36cb21ffd2bbee8e) Conflicts: src/common/OutputDataSocket.cc src/common/OutputDataSocket.h --- src/common/OutputDataSocket.cc | 17 ++++++++++++----- src/common/OutputDataSocket.h | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/common/OutputDataSocket.cc b/src/common/OutputDataSocket.cc index d17ae9022eff0..eaced2f2b3dbe 100644 --- a/src/common/OutputDataSocket.cc +++ b/src/common/OutputDataSocket.cc @@ -92,6 +92,7 @@ OutputDataSocket::OutputDataSocket(CephContext *cct, uint64_t _backlog) m_shutdown_wr_fd(-1), going_down(false), data_size(0), + skipped(0), m_lock("OutputDataSocket::m_lock") { } @@ -290,12 +291,12 @@ void OutputDataSocket::handle_connection(int fd) int OutputDataSocket::dump_data(int fd) { m_lock.Lock(); - list l = std::move(data); + vector l = std::move(data); data.clear(); data_size = 0; m_lock.Unlock(); - for (list::iterator iter = l.begin(); iter != l.end(); ++iter) { + for (auto iter = l.begin(); iter != l.end(); ++iter) { bufferlist& bl = *iter; int ret = safe_write(fd, bl.c_str(), bl.length()); if (ret >= 0) { @@ -385,11 +386,17 @@ void OutputDataSocket::append_output(bufferlist& bl) Mutex::Locker l(m_lock); if (data_size + bl.length() > data_max_backlog) { - ldout(m_cct, 20) << "dropping data output, max backlog reached" << dendl; + if (skipped % 100 == 0) { + ldout(m_cct, 0) << "dropping data output, max backlog reached (skipped==" + << skipped << ")" + << dendl; + skipped = 1; + } else + ++skipped; + return; } - data.push_back(bl); + data.push_back(bl); data_size += bl.length(); - cond.Signal(); } diff --git a/src/common/OutputDataSocket.h b/src/common/OutputDataSocket.h index 0bce1ded790de..7e5897102873a 100644 --- a/src/common/OutputDataSocket.h +++ b/src/common/OutputDataSocket.h @@ -53,13 +53,13 @@ protected: bool going_down; uint64_t data_size; + uint32_t skipped; - std::list data; + std::vector data; Mutex m_lock; Cond cond; - - bufferlist delim; + buffer::list delim; }; #endif -- 2.39.5