2012/4/6 Konstantin Kolinko <[email protected]>:
> 2012/4/6 Ofer Israeli <[email protected]>:
> > Hi Konstantin,
> >
> > I agree regarding the OOM bringing TC to a state where it must be
> restored, but my point remains: if there is code that handles catching this
> exception and terminating the thread, why not terminate gracefully by
> closing the listening socket before killing the thread?
> >
>
> 1. In theory one can configure several acceptor threads. Though it is not
> recommended.
> So one has to check the count before closing the socket.
This sounds like the reason for not closing the socket. Is this a TC
configuration?
> 2. The socket will be closed when Tomcat shuts down.
> Just closing the socket - what will it improve?
>
> Anyway you will need to shutdown this Tomcat instance before you can start
> the second one, because you'll need to free the shutdown port etc.
The point is to do proper cleanup when terminating a thread. One good reason
for this is the strange situation the system is left in where you can see that
the Tomcat process is listening on port 8009 via netstat, yet it actually isn't
listening on that port as the acceptor thread has died. This makes it very
difficult to troubleshoot as the system is showing "false" information.
> > if there is code that handles catching this exception and terminating
> > the thread
>
> 3. There is no such special code. The thread terminates by itself, because its
> run() throws an exception and thus finishes execution.
>
> There is ThreadGroup.uncaughtException() method in JRE which by default
> prints the exception to stdout.
I see specific Tomcat code that catches Throwable, prints out this exception
and then terminates the thread in ThreadPool:
ThreadPool.log.error(sm.getString
("threadpool.thread_error", t,
toRun.toString()));
By the way, this is not relevant only for OOME, but also for any other
exception that was not handled and reached this code.
> If you consider to propose a patch - feel free to file an enhancement request
> in Bugzilla and attach it.
In accordance with your comments on the above, I'll file a patch if it looks in
place.
Thanks,
Ofer
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]