Opened 5 years ago

Closed 4 years ago

#2195 closed defect (fixed)

"Timer already cancelled" when trying to log in

Reported by: Nicklas Nordborg Owned by: everyone
Priority: major Milestone: BASE 3.15.3
Component: core Version:
Keywords: Cc:


When trying to log in I get an stack trace:

Timer already cancelled.
java.lang.IllegalStateException java.base/java.util.Timer.sched( java.base/java.util.Timer.schedule( Keyring.reload( Keyring.getAllPermissions( SessionControl.createLoginInfo( SessionControl.login( org.apache.jsp.login_jsp._jspService( org.apache.jasper.runtime.HttpJspBase.service(

For some reason the timer used by the BASE core to perform some regular tasks (such as re-loading access permissions for logged in user) has been stopped. Explicit calls for stopping the timer only exists in the Application.stop() method and in this case we wouldn't get the login page at all.

The timer may also be stopped by an uncaught exception being passed out from a tasks run() method. I found this in the Tomcat's log file:

Exception in thread "Base2Core.Timer" java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
  at java.base/java.lang.Thread.start0(Native Method)
  at java.base/java.lang.Thread.start(
  at java.base/java.util.TimerThread.mainLoop(
  at java.base/

It actually seems like we can't blame any of the actual tasks that has been scheduled, but there is a problem with starting the thread that should execute the task. The OutOfMemoryError is probably also a bit misleading. A quick search on Google returns several hits that indicate that it is more likely related to a limit on the number of threads. So we can probably catch (and log) that situation in our method and prevent the timer from dying.

However, this also means that the task is not executed and if the problem persists it may have other side-effects.

Change History (3)

comment:1 by Nicklas Nordborg, 4 years ago

Milestone: BASE 3.16BASE 3.15.3

comment:2 by Nicklas Nordborg, 4 years ago

In 7755:

References #2195: "Timer already cancelled" when trying to log in

Added try/catch in the ThreadTimerTask implementation. This should prevent the built-in timer in BASE from stopping and hopefully prevent problems caused by that.

comment:3 by Nicklas Nordborg, 4 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.