Getting a lot of "controller thread [611849814] forced to stop after 50456ms"

Using “Log Viewer” extension in Lucee Server Administrator
I get a lot of errors similar to the below:

application.log ERROR 00:10:17, 17 Mar, 2025 Thread-3
“controller thread [143837866] forced to stop after 50117ms”

I can’t seem to narrow down to one of the web context as it’s only shown at the server context.

Hosting several websites but nothing busy in particular.
Websites are running mostly fine but the errors keep showing in the log and it worries me. Trying to solve it before it grows into a bigger problem.

TIA.

Lucee 5.4.4.38
Windows Server 2022 Standard
Apache Tomcat 9.0.62 Server
IIS 10 (BonCodeAJP13)

The controller thread in 5.4 does a range of cleanup

  • purging old temp and cache files
  • expiring old scopes (do you have code doing work in onSessionEnd?)
  • GC every 5 mins (no longer in 6.2 by default)
  • checking expired data source connections
  • checking for config changes

One thing to check, are you cleaning up temp files created by your code?

If the server is under load, this might also take longer due to thread priority

If you are running multiple sites (contexts) the controller thread is going to visit each context.

1 Like

Thanks Zackster for the reply.

So basically this is common and expected behavior/internal operation?
They were reported as errors under application.log that’s why it freaked me out somewhat.

There was only once the GC wasn’t able to claim back the heap, it went consistently between 97% and 99% for a while until I restarted Tomcat/Lucee.

Apologies, I’m not entirely sure what you meant by “cleaning up temp files created by my code”. Appreciate if you can give some example operations and where it created the temp files, so I can start doing some manual cleaning.

I’m running multiple sites of low/medium traffic and mostly legacy code using Application.cfm. For the few that I run Application.cfc I don’t run anything inside onSessionEnd().

That being said, should I do something to mitigate the behavior or just leave it as it is?

TIA

What I mean by temp files, is do you every write files using getTempFile() or getTempDirectory() but don’t delete them afterwards?

As you’re running an old version of Lucee and Tomcat and probably java too, I’d suggest upgrading

I never use getTempFile() or getTempDirectory() when uploading files. I only use <cffile action="upload" destination="#expandpath("./folder123")#"> but never written any code to “clean up”. Am I doing it wrong? Is this the reason?

are you using database storage for sessions or client variables?

No, only use cookie for client storage. Furthermore most of the websites don’t require a login. However both session and client are enabled. I notice sometimes the first visit to one website takes way longer (up to 5s, like a “cold start”) but subsequent visits to other pages are instantaneous.