Skip to content

worker : Redis connection timeout, quitting #1968

Closed

Description

@Miracles666

my code:

image

I used nohup Python worker. py to start the worker

ps -aux | grep "worker.py"
root 344745 1.5 1.0 114868 26960 pts/2 Sl 18:00 0:00 python3 worker.py --queue worker_1--processes 1 root 344754 1.5 1.0 114868 26972 pts/2 Sl 18:00 0:00 python3 worker.py --queue worker_2 --processes 1 root 344757 1.5 1.0 114868 27044 pts/2 Sl 18:00 0:00 python3 worker.py --queue worker_3 --processes 1 root 344759 1.5 1.0 114868 27000 pts/2 Sl 18:00 0:00 python3 worker.py --queue worker_4 --processes 1

After a period of time: Worker rq:worker: worker_1: Redis connection timeout, quitting...

ps -aux | grep "worker.py"
root 344648 0.0 0.0 9036 656 pts/2 S+ 18:00 0:00 grep --color=auto worker.py
It seems that all my workers have been killed. Is there any way I can ensure that the workers can automatically connect?

Activity

  1. Miracles666 commented on Aug 29, 2023

    @Miracles666
    Author

    It seems that using a while loop can solve the problem

  2. Miracles666 commented on Feb 22, 2024

    @Miracles666
    Author

    It seems that the while loop cannot solve this problem. I still encountered the problem of worker disconnection but not reconnection in the later stage

  3. ssikiki commented on Mar 19, 2024

    @ssikiki

    +1, It can be reproduced when the network with the redis server is disconnected, and it will not attempt to reconnect
    but when redis process is killed, it can trigger reconnection

  4. alor commented on Apr 5, 2024

    @alor

    facing similar issue, and I can't understand why the try/except is not catching the exception

  5. IngLP commented on Feb 13, 2025

    @IngLP

    +1, same problem

  6. lorentsi commented on Feb 28, 2025

    @lorentsi

    Hello, we ran into the same issue using
    rq worker --url "redis://redis" queue_name, does anyone have a solution for this? It happens both in RQ 2.1 and 1.16.2.
    The only solution we have found yet is that kill the worker and restart it manually.

    EDIT: After further investigation, the issue is that the worker exit with a success status, which means or docker config "on-failure" restart doesn't work. I think the worker should have an error exit code when it exits with a de-connection error.

  7. tyler-8 commented on Mar 18, 2025

    @tyler-8

    After further investigation, the issue is that the worker exit with a success status, which means or docker config "on-failure" restart doesn't work. I think the worker should have an error exit code when it exits with a de-connection error.

    This is a key point and something I've observed as well with systemd running an rq service. Restart=on-failure doesn't have any impact because the service appears to be stopping gracefully with an exit code of 0.

    Log output sample:

    python[997]: ERROR Worker rq:worker:584kwdgdfg36597mhn8476903nc8: Redis connection timeout, quitting...
    python[2600]: INFO Scheduler stopping, releasing locks for default, high, low...
    python[2600]: INFO Scheduler with PID 2600 has stopped
    python[997]: INFO Unsubscribing from channel rq:pubsub:584kwdgdfg36597mhn8476903nc8
    systemd[1]: rq-app.service: Deactivated successfully.
    systemd[1]: rq-app.service: Consumed 49.451s CPU time.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions