如果芹菜工人辛苦去世,工作会被重试吗?

编程入门 行业动态 更新时间:2024-10-20 13:28:47
本文介绍了如果芹菜工人辛苦去世,工作会被重试吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

更多推荐

如果芹菜工人辛苦去世,工作会被重试吗?

本文发布于:2023-11-23 20:48:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622819.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作会   芹菜   重试   工人   辛苦

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!