如果工人所在的服务器死亡,是否可以重试芹菜作业?我不仅指执行作业的子流程,而且整个服务器不可用.
我尝试过用RabbitMQ和Redis作为经纪人.在这两种情况下,如果当前正在处理作业,则将其完全遗忘.当工作人员重新启动时,它甚至没有尝试重新处理作业,并且看着Rabbit或Redis,他们的队列是空的.结果后端也为空.
工作人员似乎抓住了消息,并假设如果子进程失败,消息将被放回去,但是如果工作人员也死了,则无法将其放回去.
(是的,我在这样的环境中工作,这种情况每年发生不止一次,并且我不想丢失任务)
解决方案理论上,设置 task_acks_late = True 应该可以解决问题.(文档)
使用Redis代理,任务将在 visibility_timeout (默认为一小时)之后重新交付.(文档)
使用RabbitMQ,一旦Rabbit注意到工人死亡,任务就会重新发送.
Is there a way for a celery job to be retried if the server where the worker is running dies? I don't just mean the sub-process that execute the job, but the entire server becomes unavailable.
I tried with RabbitMQ and Redis as brokers. In both cases, if a job is currently being processed, it is entirely forgotten. When a worker restarts, it doesn't even try to reprocess the job, and looking at Rabbit or Redis, their queues are empty. The result backend is also empty.
It looks like the worker grabs the message and assume it will put it back if the subprocess fails, but if the worker dies also, it can't put it back.
(yes, I work in an environment where this happens more than once a year, and I don't want to lose tasks)
解决方案In theory, set task_acks_late=True should do the trick. (doc)
With a Redis broker, the task will be redelivered after visibility_timeout, which defaults to one hour. (doc)
With RabbitMQ, the task is redelivered as soon as Rabbit noticed that the worker died.
更多推荐
如果芹菜工人辛苦去世,工作会被重试吗?
发布评论