-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] crontab在k8s集群下会导致无法执行 #7005
Comments
设置 OnOneServer ,拿到锁的server执行定时任务时,pod突然重启,锁没能释放,会导致这种问题,也无法避免,只能等锁超时。 |
这个锁至少锁了1个小时以上,具体多长时间我倒是没测过 |
追源码可以看到,默认锁3600秒,也就是1小时。 |
不过你的临时方案没有设置OnOneServer,setMutexExpires 其实也是不起效的,存在多个pod并发执行定时任务的情况。 |
crontab 建议自己控制下,参数太多,感觉调参数的成本也挺高的 |
看日志没并发,可能节点不够多,工作日我加OnOneServer试试 |
这个锁是最大的加锁时长。 你锁60秒,01秒加锁,30秒重启服务器,肯定只锁30秒了。。。 如果你希望每次重启后立即执行,就去掉框架提供的锁,自行在要执行的定时任务里做好防并发、防重复执行的逻辑 |
Execute the command and paste the result below.
Description:
服务器情况:
3台服务器,60个k8s pod节点平均分配到每台机20个容器
Steps To Reproduce:
1.首次发布定时任务代码,正常运行
2.第二次在定时任务代码里面加点注释,然后再发布,执行日志如下:
代码发布前最后一条记录时间2024-08-16 14:11:33
代码发布后第一条记录时间2024-08-16 14:12:00
看完日志第一时间想到是抢锁出问题,后面看了文档发现还可以用redis,所以就用了下面的方案
目前的临时解决方案:
把setOnOneServer换成setMutexPool
执行日志如下:
The text was updated successfully, but these errors were encountered: