查看日志,发现 redis socket 报错

2021-03-15 10:55:01 +08:00
 awanganddong

业务场景是群发微信消息, 现在单一的生产者消费者模式

查看业务日志有下列报错

socket error on read socket

查看 redsi.log 没发现报错

搜索上说是消费者速度太慢,所以系统输出缓冲区大小的限制。

对这里不清楚, 可以帮忙分析怎么排查此类问题的思路吗

1548 次点击
所在节点    Redis
4 条回复
ebingtel
2021-03-15 18:10:27 +08:00
redis server 端部分场景会剃掉客户端 比如内存占用大、client 查询参数超长等 可以看看……
awanganddong
2021-03-15 21:42:42 +08:00
@ebingtel 看代码提示这里报错的
```
-- Get all of the jobs with an expired "score"...
local val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])

-- If we have values in the array, we will remove them from the first queue
-- and add them onto the destination queue in chunks of 100, which moves
-- all of the appropriate jobs onto the destination queue very safely.
if(next(val) ~= nil) then
redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)

for i = 1, #val, 100 do
redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))
-- Push a notification for every job that was migrated...
for j = i, math.min(i+99, #val) do
redis.call('rpush', KEYS[3], 1)
end
end
end
```

也就是 zrangebyrank 这里获取数据出现问题
ebingtel
2021-03-16 09:05:54 +08:00
@awanganddong 只看这个 看不出来 …… 是必现(调大服务器资源后,如果还必现,应该是代码问题) 还是 偶发(多半不是代码问题) ? 需要看看连接&内存情况 https://redis.io/topics/clients
awanganddong
2021-03-16 09:47:10 +08:00
@ebingtel 出现过几次这种情况。
我现在追了下 php 代码,引起这个原因的代码是这里。
现在打算追下 redis 代码,看看这个异常从那里来的。
然后再做分析,
主要是查看同时间段 redis.log 日志是正常的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/761696

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX