awanganddong
V2EX  ›  Redis

查看日志,发现 redis socket 报错

  •  
  •   awanganddong · Mar 15, 2021 · 2162 views
    This topic created in 1884 days ago, the information mentioned may be changed or developed.

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

    查看业务日志有下列报错

    socket error on read socket
    

    查看 redsi.log 没发现报错

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

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

    4 replies    2021-03-16 09:47:10 +08:00
    ebingtel
        1
    ebingtel  
       Mar 15, 2021
    redis server 端部分场景会剃掉客户端 比如内存占用大、client 查询参数超长等 可以看看……
    awanganddong
        2
    awanganddong  
    OP
       Mar 15, 2021
    @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  
       Mar 16, 2021
    @awanganddong 只看这个 看不出来 …… 是必现(调大服务器资源后,如果还必现,应该是代码问题) 还是 偶发(多半不是代码问题) ? 需要看看连接&内存情况 https://redis.io/topics/clients
    awanganddong
        4
    awanganddong  
    OP
       Mar 16, 2021 via Android
    @ebingtel 出现过几次这种情况。
    我现在追了下 php 代码,引起这个原因的代码是这里。
    现在打算追下 redis 代码,看看这个异常从那里来的。
    然后再做分析,
    主要是查看同时间段 redis.log 日志是正常的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   930 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:20 · PVG 05:20 · LAX 14:20 · JFK 17:20
    ♥ Do have faith in what you're doing.