memcached 导致 Apache 进程无限期挂起

memcached 导致 Apache 进程无限期挂起

我一直在追踪 Apache 进程无限期挂起的原因。不幸的是,我需要定期重启 Apache,因为它最终会耗尽所有插槽。下面的 Apache 状态页面显示处于挂起状态的进程W - Sending Reply- 它们永远不会消失,只会不断累积,直到达到 ServerLimit。

在此处输入图片描述

strace -ff -p {pid}在一个 Apache 进程上运行它,直到它最终挂在“W - 发送回复”状态,下面是 strace 输出(我删除了不相关的 strace 输出):

connect(13, {sa_family=AF_INET, sin_port=htons(11211), sin_addr=inet_addr("XXX")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=13, events=POLLOUT}], 1, 10)  = 1 ([{fd=13, revents=POLLOUT}])
sendto(13, "get mcalls_e7e0891d35db253e26a31"..., 45, MSG_NOSIGNAL, NULL, 0) = 45
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "END\r\n", 8196, MSG_NOSIGNAL, NULL, NULL) = 5
sendto(13, "get trc-mods.197194\r\n", 21, MSG_NOSIGNAL, NULL, 0) = 21
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "END\r\n", 8196, MSG_NOSIGNAL, NULL, NULL) = 5
sendto(13, "set trc-mods.197194 5 1659718696"..., 2799, MSG_NOSIGNAL, NULL, 0) = 2799
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "STORED\r\n", 8196, MSG_NOSIGNAL, NULL, NULL) = 8
sendto(13, "get uonline_1354585\r\n", 21, MSG_NOSIGNAL, NULL, 0) = 21
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "END\r\n", 8196, MSG_NOSIGNAL, NULL, NULL) = 5
sendto(13, "get grps_1354585\r\n", 18, MSG_NOSIGNAL, NULL, 0) = 18
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "VALUE grps_1354585 5 6\r\n\0\0\0\2\24\0\r\n"..., 8196, MSG_NOSIGNAL, NULL, NULL) = 37
sendto(13, "get trc-mods.197129\r\n", 21, MSG_NOSIGNAL, NULL, 0) = 21
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "END\r\n", 8196, MSG_NOSIGNAL, NULL, NULL) = 5
sendto(13, "set trc-mods.197129 5 1659718696"..., 2308, MSG_NOSIGNAL, NULL, 0) = 2308
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "STORED\r\n", 8196, MSG_NOSIGNAL, NULL, NULL) = 8
sendto(13, "get trc-modcats.8279\r\n", 22, MSG_NOSIGNAL, NULL, 0) = 22
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(13, "set trc-modcats.8279 5 165971869"..., 318, MSG_NOSIGNAL, NULL, 0) = 318
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(13, "get trc-mods.211005\r\n", 21, MSG_NOSIGNAL, NULL, 0) = 21
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "VALUE trc-modcats.8279 5 277\r\n\0\0"..., 8196, MSG_NOSIGNAL, NULL, NULL) = 314
sendto(13, "set trc-mods.211005 5 1659718696"..., 2149, MSG_NOSIGNAL, NULL, 0) = 2149
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 1 ([{fd=13, revents=POLLIN}])
recvfrom(13, "STORED\r\nEND\r\nSTORED\r\n", 8196, MSG_NOSIGNAL, NULL, NULL) = 21
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)
getsockopt(13, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
recvfrom(13, 0x556c1ea68810, 8196, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN}], 1, 5000) = 0 (Timeout)

根据此输出,我相信该问题与 memcached 有关。

/var/log/messages显示了这些错误在挂起进程建立时累积:

Aug  5 15:27:43 myhost memcached[3752802]: Failed to write, and not due to blocking: Broken pipe
Aug  5 15:27:43 myhost memcached[3752802]: Failed to write, and not due to blocking: Broken pipe
Aug  5 15:28:02 myhost memcached[3752802]: Failed to write, and not due to blocking: Broken pipe

我注意到的另一件事是,当这些挂起的进程累积时,它们会同时在所有 3 个 Apache 服务器上累积(见下文)。悬崖代表 Apache 重新启动,并且在截图时挂起的进程才刚刚开始再次累积。

在此处输入图片描述

有人遇到过这种情况吗?或者有人对我该怎么做有什么建议吗?

眼镜:

  • AlmaLinux 8.5
  • Apache 2.4.37
  • 带有 PECL Memcached 3.2.0 和 libmemcached-awesome 1.1.1 的 PHP 8.1.4
  • memcached 1.6.15(守护进程)

答案1

经过一周的反复试验,我想我终于解决了这个问题,尽管我在监视 Apache 状态页面上是否存在挂起进程时非常谨慎,因为我尝试了很多方法但都没有奏效。

我的解决方案并没有解决根本问题,我认为该问题可能是 libmemcached 或 php-pecl-memcached 中的一个错误。

我的解决方案是在我的应用程序内缓冲 memcachedset()delete()调用,并在脚本关闭时使用立即运行它们register_shutdown_function(),而不是将它们分散在各个类中并与调用一起实时运行它们get()

此策略存在一些问题(竞争条件等),因此如果您尝试此策略,请仔细测试您的代码。我应该补充一点,这种方法为使用提供了一个很好的机会setMulti(),但是,显然这种方法从未在 php-pecl-memcached 中正确实现(它只是运行一个set调用循环)。

这次讨论对了解我的情况非常有帮助。

相关内容