High CPU usage - due to scheduled tasks

As soon as I put back my scheduled tasks and restart Lucee with Lucee-Tomcat Service Control, CPU at 50% again. Many threads about ScheduledTaskThread. I’ll try to add my scheduled tasks one by one to see which combination provoke that. Note that all scheduled tasks are on pause…

There’s some certain combinations of scheduled task intervals which get stuck in an infinite loop trying to find the next schedule

Is this bug has been already reported?

I wonder if I should use something else than Lucee to manage the scheduled tasks…

This is sort of a side-question, but the fact that the Lucee restart button didn’t stop those scheduled task threads is probably a bug in itself. The Lucee service restart actually shuts down the JVM and starts a fresh one. The Lucee restart button leaves the JVM and the servlet container (tomcat) and simply unloads and reloads the Lucee context in memory. IMO, that should include any scheduled task threads.

Is this bug has been already reported?

Yes. That’s how Zac knows about it :slight_smile:

https://luceeserver.atlassian.net/browse/LDEV-3214

1 Like

Thank you @Zackster and @bdw429s

I’ll wait for a patch and if the patch don’t come in time, I will track down the scheduled task that provoke it or use another tool to manage the scheduled tasks instead of Lucee.

If you could isolate which task(s) are causing the problem before it get addressed, that would be super useful…

I’ll do that with pleasure then!

Cool.

The admin restart bug may have been fixed in 5.3.8 btw

1 Like

I found one of the scheduled task. This one alone provoke a 25% CPU usage non-stop. When I try a different interval like 1000 it’s okay.

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?><schedule><task autoDelete="false" endTime="{t '23:59:59'}" hidden="false" interval="14400" name="To Infinity and Beyond" paused="true" port="443" proxyHost="" proxyPassword="" proxyPort="0" proxyUser="" publish="false" readonly="false" resolveUrl="false" startDate="{d '2021-01-01'}" startTime="{t '00:00:00'}" timeout="90000" unique="true" url="https://www.example.com/infinity/"/></schedule>

Use the profile feature in FR to profile the thread for a few seconds and then see what it is doing. The previous issues with scheduled tasks was due to an infinite loop int he code trying to figure out when to run the task next.

I just added in thread CPU time to my Performance Analyzer plugin v1.0.1.2 (available via admin)

2 Likes

Hi! I installed the new version of your plugin @Zackster.

As soon I add the scheduled task To Infinity and Beyond and restart Lucee, I see this :

After few seconds I see CPU time jumping at 286,281.25, then 316,234.38, then 332,750.00, and going up and up and up…

1 Like

I tried to find a pattern for the bug. It’s directly related to the scheduled task interval :

  • 10000 (2,777778 hours) ok
  • 10400 (2,8888889 hours) ok
  • 10800 (3 hours) bug
  • 10810 (3,0027778 hours) ok
  • 14400 (4 hours) bug
  • 14700 (4,0833333 hours) ok
  • 18000 (5 hours) ok

At first I thought it was coming from a rounding issue and/or data type (int vs float), because it was buggy just with whole number like 3 and 4 hours, but it’s okay with 5 hours. It’s strange.

For now I just changed the interval 14400 to 14700 for my problematics scheduled tasks and the Lucee CPU dropped at 0%.

I wonder if it’s specific to our server configuration or if anybody who use an interval of 14400 will have this issue…

If I can help in anyway to solve this issue, let me know!

1 Like

I think it’s maybe something to do with this while(true) loop in revertDST

the code is slightly different in 5.3 as it includes a fix for this issue with DST

It makes sense.

Note that if my scheduled task use an interval of 14400 and start at {t ‘06:00:00’}, it’s fine. But if it’s start at 00:00:00, or 00:30:00, or 01:00:00 the bug still occur. This is indeed a bug depending on the combination of start time and interval, and maybe end time as well.

good detective work, can you post your findings in the task

I posted my findings in the bug report [LDEV-3214] - Lucee.

1 Like

this was addressed in 5.3.8.156, please try it out (when the build finishes)

1 Like

I too also had scheduled tasks high cpu when converting from railo to lucee. I binnary searched around 250 tasks and found 5 offenders. No rhyme or reason to what they were

Hi @Zackster,

I don’t see the version 5.3.8.156 in the Update section of the server admin. Is it normal?

I suppose the version 5.3.8.159-SNAPSHOT should be fine too? I tried the version 5.3.8.159-SNAPSHOT with my old scheduled tasks settings and everything look normal in the CPU usage.

Thank you!

1 Like

I had the same problem and by turning off Debugging*, everything was fine again.