From c40ab6bcdb294d906efe5aa3433b55a839c54b0e 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) --- src/common/OutputDataSocket.cc | 19 +++++++++++++------ src/common/OutputDataSocket.h | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/common/OutputDataSocket.cc b/src/common/OutputDataSocket.cc index daba820cf05a..fd01504487ff 100644 --- a/src/common/OutputDataSocket.cc +++ b/src/common/OutputDataSocket.cc @@ -93,7 +93,8 @@ OutputDataSocket::OutputDataSocket(CephContext *cct, uint64_t _backlog) m_shutdown_rd_fd(-1), m_shutdown_wr_fd(-1), going_down(false), - data_size(0) + data_size(0), + skipped(0) { } @@ -291,12 +292,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) std::lock_guard 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.notify_all(); } diff --git a/src/common/OutputDataSocket.h b/src/common/OutputDataSocket.h index e974d1b58c5d..682dfcc6cb65 100644 --- a/src/common/OutputDataSocket.h +++ b/src/common/OutputDataSocket.h @@ -55,13 +55,13 @@ protected: bool going_down; uint64_t data_size; + uint32_t skipped; - std::list data; + std::vector data; ceph::mutex m_lock = ceph::make_mutex("OutputDataSocket::m_lock"); ceph::condition_variable cond; - - bufferlist delim; + buffer::list delim; }; #endif -- 2.47.3