如果芹菜工人辛苦去世,工作会被重试吗? [英] If celery worker dies hard, does job get retried?

查看:42
本文介绍了如果芹菜工人辛苦去世,工作会被重试吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果工人所在的服务器死亡,是否可以重试芹菜作业?我不仅指执行作业的子流程,而且整个服务器不可用.

我尝试过用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.

这篇关于如果芹菜工人辛苦去世,工作会被重试吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆