-
Notifications
You must be signed in to change notification settings - Fork 627
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
cron job stops after certain hours. #232
Comments
I can confirm this bug, it was a pain to debug, because i thought the problem was on my side. |
I had the same issue...for me, it runs for a few days just fine - I have an hourly cron - and 2 days ago it stopped with no errors in the node log. |
I can confirm as well, i have cronjob running each second, but hangs after a while. The issue for me is critical because i am switching off water pump (when i do not have enough water in my well).
Any help would be apreciated. |
Same problem here. I did not find any reason for that to happen in my code (every error is logged with sentry, and nothing particular happen) |
I have seen this problem also. We have an every minute cron job that runs for days and days and then just stops. I'm tracking the duration between ticks and its normally 60 seconds. The last tick before it stopped was 147 seconds. Maybe this has something to do with the root cause ? |
yes i too suspecting it @colmaengus |
Hello guy's. |
We are seeing this quite a lot now. Adding some extra logs it looks to be when node is running so slowly that the next tick time comes around while you are trying to figure out what that next time should be. Apart from the discrepancy of some seconds in the logs it would appear that _getNextDateFrom took so long to run that the next time to tick had come around already. The cron job was set to run every minute so there should have only been max 60 iterations through the while loop so I don't know what would cause the extreme slowdown. Apart from the node.js process in general being starved of cpu cycles.
|
We are also facing same issue . Our job runs every second and it works perfectly for a day or max 2 days but after that we don't see any logs , connections to DB are also lost . it just hangs .... Restarting the job again works fine. till now i was thinking its code issue but other people are also facing the same issue. Please let us know if there is work around for this or otherwise we will have to change the module. Help is appreciated |
This issue is the same as #231 - I'm looking into this now. Sorry for the delayed response. I've had no time to look into my open source projects. Thanks for digging into it - I'll share anything I find here. |
Keep us posted, thanks! |
Is this fixed in 1.3? With 1.1 I still having the problem. |
Unfortunately error is still there. Cron just stops after certain hours without any error message :( |
As a workaround I'm using the onComplete event and if it is meant to be still running I call start again. |
Error is still there on version 1.3 |
I really don't understand why in start function if timeout < 0 function stop is called. |
I've merged in a few prs that should help with this. Please let me know if you're still having the issue. @Alessy negative timeouts aren't valid. I could change the behavior to just keep going, but it would likely cause a skip. Really this should either send a warning to the console or |
Closing for now. If this is still an issue we can take it as a new issue. |
Anyone knows which commit is for this fix? |
Does 1.4.1 make a difference in your case? Thanks |
@hebo-hebo Same problem here. The cronjob._timeout._idlePrev = null
cronjob._timeout._idleTimeout = -1 In my experience this problem seems to happen when there are CPU intensive operations happening. The node-cron tries to create a new My temporary solution was to create another cronjob that ressurects dead cronjobs. This is how I try to find dead cronjobs // FILE: cronjob-a.js
let cronjob = new CronJob(CRON_TIME, CRON_JOB_FUNCTION);
// FILE: ressurect-cronjobs.js
for(const cronjob of GET_ALL_CRONJOBS()) {
if(cronjob._timeout._idleTimeout < 0)
RESSURECT_FUNCTION(cronjob);
} |
@dptole Interesting. It would be great to have something like this built into the library, but if it can't get the timeout then it likely wont succeed at getting a new one a few ticks later and it doesn't make sense to use a timeout to try to get a new timeout. For now it makes sense to me to use the approach that you are here and I'll mull this around a bit. |
How about the following ?
I'm doing pretty much this in an external wrapper. |
@colmaengus correct me if I'm wrong but what I grasped from what @ncb000gt said was:
Unless you are doing these checks without the setTimeout/setInterval functions (although I think it is being done internally). In my opinion, if the setTimeout/setInterval failing are core bugs, the ultimate solution would require issuing a new process to keep an eye on that. But that would required a lot more work to fix an issue that happens in very specific use cases. Maybe the README.md should be updated to warn people of this issue could help... maybe an issue should be created on the nodejs core library... I don't know. But a final solution, I think, should come from v8/nodejs releases. |
@colmaengus @dptole I'd be very skeptical that timers and intervals were somehow not working in node code. I would definitely assume it's the library before suspecting the node implementation. @colmaengus I think that sounds reasonable. It should already check to see if the job is a one shot or periodic job and there is some checking to determine if the timeout is too large. Clearly, we need the opposite. |
Saw it happened three times on my two different servers. Is there a utility like pstack or jstack, which can peek into the node.js application to see where it got stuck. Or would it be possible to emit log messages when it runs into this situation (no more launch of cron jobs)? So we can confirm the root cause for sure. |
hello guys, this bug is still not fixed in 2.0.3 ? or Anyone knows which commit is for this fix? i'm using version 1.1.0, and found cronjob will be stoped when set in per second:
anyone know why this bug happend? because it is really hard to reproduce it, i had tried to create 5000 process in my server want to keep CPU and memory busy, but still not reproduce it, anyone know how to reproduce this bug? |
@zhangxiang958 The module is at 1.6.0. I'd recommend trying that version. As far as reproduction, that's part of the problem. People are/were hitting it, but it's not easy to recreate in a test. I made some changes to the module with the latest version in the middle of December. Try that version and let me know if you're still running into this. |
My two servers are using the old cron version version '1.1.0'. There are 4 tasks configured and each runs every four minutes. The cron does not fire any more jobs after 25 days. Already happened 3 times on my two servers. Curious to know if there was any bug like that? |
@hebo-hebo There have been reports like that in the past. The cases have varied related to timezones to a couple other possible causes. So far, in the latest version we haven't seen reports of this. So, presumably the issue is resolved. Please let us know if you see this behavior on the latest version. Thanks! |
Out production tests shows that a Job failed to execute due to node-cron job that did not 'tick'. The cron defined as "14 */1 * * * *", successfully executed every minute, but stopped at 4am for some reason. |
@eranbetzalel You can do what you feel is best obviously. Sorry that the job didn't execute. Which version of the module were you using? What were the conditions on the system, high load and what kind of processing was the ontick handling for you? |
You're right, forgot to mention that. Version 1.6.0 I didn't see any CPU high-load in Google's CPU graphs. The on tick ran a lambda expression that run some job execution... |
@eranbetzalel The latest version is 1.7.0 to fix an issue related to DST found in GH-408. Given the time frame I suspect this may be what happened. Would you be interested in confirming? |
I'll look into it whenever I'll have some free time, probably not in the near future. |
@eranbetzalel ok. regardless, thanks for letting me know you ran into an issue. |
Problem is still there, just to let you all know |
I can also confirm the issue still exists |
Just experienced this issue, still needed to fix. |
Another one to confirm this exists. I thought my server had a memory leak and I was investigating why it crashed. Took me weeks to fix. In the end I replaced node-cron and all my problems disappeared. Sorry to say that, but that's a really bad bug, especially if no error is thrown when the server crashes. |
I think I experienced this bug today also. Hard to know since I couldn't set a breakpoint and debug, but everything matches: 1 second cron job, no error thrown. |
Same problem for mere on AWS tiny instances with low cpu and ram |
I have scheduled cron on the server but it gets stopped automatically after 1-2 days or sometimes later. |
|
Hey guys, this is still hapening on version 3.0.0. Same symptoms, no exceptions, no warnings nothin, it simply stops executing the cronjob. This usually happens between 4-6 hours for me. |
that's crazy seeing as we're only on version 2.3.1. what do you have installed in your package.json? |
Omg I have to say I was wrong. This was happening on the library node-cron, and I had two tabs opened and I made the comment on the wrong one. I'm so sorry for the trouble. All is well, this is the one that actually works, Again, sorry. |
no worries haha. feel free to switch if you want |
var job = new CronJob({
cronTime: '/1 * * * * *',
onTick:function() {
console.log(new Date, 'tick triggered');
},
onComplete: function(){/*/},
start: true,
runOnInit: true
});
job.start();
this job hanged & not seeing any logs after certain hours of execution. i am using nodejs 6.1.0 & cron 1.1.0
is cron supports every second jobs && if we not mentioned timezone which time zone takes for the job?
Thanks
The text was updated successfully, but these errors were encountered: