Merge branch '2.2' into develop
This commit is contained in:
@ -175,12 +175,57 @@ bool MessageQueue::post(const Message& message) const
|
||||
ss_dassert(m_pWorker);
|
||||
if (m_pWorker)
|
||||
{
|
||||
ssize_t n = write(m_write_fd, &message, sizeof(message));
|
||||
rv = (n == sizeof(message));
|
||||
/**
|
||||
* This is a stopgap measure to solve MXS-1983 that causes Resource temporarily
|
||||
* unavailable errors. The errors are caused by the pipe buffer being too small to
|
||||
* hold all worker messages. By retrying a limited number of times before giving
|
||||
* up, the success rate for posted messages under heavy load increases
|
||||
* significantly.
|
||||
*/
|
||||
int fast = 0;
|
||||
int slow = 0;
|
||||
const int fast_size = 100;
|
||||
const int slow_limit = 3;
|
||||
ssize_t n;
|
||||
|
||||
while (true)
|
||||
{
|
||||
n = write(m_write_fd, &message, sizeof(message));
|
||||
rv = (n == sizeof(message));
|
||||
|
||||
if (n == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
||||
{
|
||||
if (++fast > fast_size)
|
||||
{
|
||||
fast = 0;
|
||||
|
||||
if (++slow >= slow_limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sched_yield()
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (n == -1)
|
||||
{
|
||||
MXS_ERROR("Failed to write message: %d, %s", errno, mxs_strerror(errno));
|
||||
|
||||
static bool warn_pipe_buffer_size = true;
|
||||
|
||||
if ((errno == EAGAIN || errno == EWOULDBLOCK) && warn_pipe_buffer_size)
|
||||
{
|
||||
MXS_ERROR("Consider increasing pipe buffer size (sysctl fs.pipe-max-size)");
|
||||
warn_pipe_buffer_size = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user