Skip to content
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

定时任务持续执行约 24 天后停止 #2964

Closed
ziyunfei opened this issue Sep 4, 2018 · 9 comments
Closed

定时任务持续执行约 24 天后停止 #2964

ziyunfei opened this issue Sep 4, 2018 · 9 comments

Comments

@ziyunfei
Copy link

ziyunfei commented Sep 4, 2018

  • Node Version: alinode-4.1.0
  • Egg Version: @ali/egg-4.2.1

每十秒执行一次的定时任务:

exports.schedule = {
  interval: '10s',
  type: 'worker',
}

exports.task = async ctx => {
...

从 8 月 9 号执行到 9 月 3 号中午自动停止,直到我 9 月 4 号晚上重启服务后继续开始执行:
image

看起来像是超过了 (2**31-1)/1000/3600/24 ≈ 24.85 天后就停止了,是我哪里用法搞错了吗?

@egg-bot
Copy link

egg-bot commented Sep 4, 2018

Translation of this issue:


The scheduled task continues to execute after about 24 days.

  • Node Version: alinode-4.1.0
  • Egg Version: @ali/egg-4.2.1

Timed tasks that are executed every ten seconds:

Exports.schedule = {
  Interval: '10s',
  Type: 'worker',
}

Exports.task = async ctx => {
...

It will stop automatically from August 9th to noon on September 3rd, and will continue to execute after I restart the service on the evening of September 4th:
image

It seems to be more than (2**31-1)/1000/3600/24 ≈ 24.85 days later, it stopped. Is it wrong with me?

@BaffinLee
Copy link
Contributor

alinode 有监控到异常吗

@ngot
Copy link
Member

ngot commented Sep 5, 2018

之前开源的 egg-schedule 已经采用了 safe-timers 修复了超过最大整数限制的问题。

不过这个问题看起来有些不同,是入参只有 10s, 但是持续执行最大整数时间后,停止了。 有些神奇。得研究下 setInterval 的机制了。

@atian25
Copy link
Member

atian25 commented Sep 6, 2018

好像最近看到谁在群里面发过,一个 Node 的 bug 修复,依稀记得就是长时间循环 setTimeout 的。不过跟这个可能无关。

@atian25
Copy link
Member

atian25 commented Sep 6, 2018

@ngot nodejs/node#22149

@ghost
Copy link

ghost commented Sep 10, 2018

@ziyunfei:Make sure that your actual execution time MUST BE smaller than your delay time defined in 'setInterval'. Just a notify for you.
For more details, please see:https://www.thecodeship.com/web-development/alternative-to-javascript-evil-setinterval/

@BaffinLee
Copy link
Contributor

症状和 node 的那个 bug 差不多,影响了 10.0 ~ 10.8 。如果是这个原因的话,升级 alinode 到 v4.3.0,对应 Node 10.9 ,可解决。

@ziyunfei
Copy link
Author

ziyunfei commented Sep 10, 2018

貌似的确已经修复了 nodejs/node#22214 ,我更新 alinode 试试。

@shiny
Copy link
Contributor

shiny commented Apr 26, 2019

我也遇到类似问题,每隔个把月左右定时器意外不更新,重启后恢复。更新下 node 版本看看会不会恢复正常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants