Skip to content

Commit

Permalink
rgw/OutputDataSocket: actually discard data on full buffer
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mattbenjamin committed Jun 5, 2019
1 parent 93c056c commit c806b82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 13 additions & 6 deletions src/common/OutputDataSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -291,12 +292,12 @@ void OutputDataSocket::handle_connection(int fd)
int OutputDataSocket::dump_data(int fd)
{
m_lock.lock();
list<bufferlist> l = std::move(data);
vector<buffer::list> l = std::move(data);
data.clear();
data_size = 0;
m_lock.unlock();

for (list<bufferlist>::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) {
Expand Down Expand Up @@ -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();
}
6 changes: 3 additions & 3 deletions src/common/OutputDataSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ class OutputDataSocket : public Thread
bool going_down;

uint64_t data_size;
uint32_t skipped;

std::list<bufferlist> data;
std::vector<buffer::list> data;

ceph::mutex m_lock = ceph::make_mutex("OutputDataSocket::m_lock");
ceph::condition_variable cond;

bufferlist delim;
buffer::list delim;
};

#endif

0 comments on commit c806b82

Please sign in to comment.