V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
awanganddong
V2EX  ›  Redis

查看日志,发现 redis socket 报错

  •  
  •   awanganddong · 2021-03-15 10:55:01 +08:00 · 1522 次点击
    这是一个创建于 1109 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    查看业务日志有下列报错

    socket error on read socket
    

    查看 redsi.log 没发现报错

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

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

    4 条回复    2021-03-16 09:47:10 +08:00
    ebingtel
        1
    ebingtel  
       2021-03-15 18:10:27 +08:00
    redis server 端部分场景会剃掉客户端 比如内存占用大、client 查询参数超长等 可以看看……
    awanganddong
        2
    awanganddong  
    OP
       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
        3
    ebingtel  
       2021-03-16 09:05:54 +08:00
    @awanganddong 只看这个 看不出来 …… 是必现(调大服务器资源后,如果还必现,应该是代码问题) 还是 偶发(多半不是代码问题) ? 需要看看连接&内存情况 https://redis.io/topics/clients
    awanganddong
        4
    awanganddong  
    OP
       2021-03-16 09:47:10 +08:00 via Android
    @ebingtel 出现过几次这种情况。
    我现在追了下 php 代码,引起这个原因的代码是这里。
    现在打算追下 redis 代码,看看这个异常从那里来的。
    然后再做分析,
    主要是查看同时间段 redis.log 日志是正常的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5271 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 09:35 · PVG 17:35 · LAX 02:35 · JFK 05:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.