If I had a method like:
private void someMethod()
{
runSqlQueryA();
runSqlQueryB();
runSqlQueryC();
}
My understanding is this method will be one thread.
In weblogic, the thread will appear stuck if it's been running for longer than 10 minutes (by default).
My question is - if these SQL queries are routinely take a long time, how do I prevent Weblogic from detecting the thread as stuck?
One option would be to simply change the stuck thread threshold, but I'm wondering if there's a better solution, such as a java thread manager that keeps it refreshed.
-
5optimize the query so it doesn't take 10 minutesratchet freak– ratchet freak2015年07月16日 22:46:17 +00:00Commented Jul 16, 2015 at 22:46
-
4Don't run them in weblogic.user40980– user409802015年07月17日 00:11:06 +00:00Commented Jul 17, 2015 at 0:11
-
Are the query results needed in the method? Do they need to be run serially?outis– outis2015年07月17日 08:27:12 +00:00Commented Jul 17, 2015 at 8:27
-
What are these queries doing and why are they running within a container? How were the threads created?user40980– user409802015年07月17日 21:38:53 +00:00Commented Jul 17, 2015 at 21:38
1 Answer 1
WebLogic is mainly a web application container. As such, anything that take minutes (more than a few seconds) to process will be suspect. Threads flagged as stuck is an indication that something may be wrong. If you end up with too many stuck threads, the server is likely to get in a very bad state. Other than modifying the times or running on an un-managed (by WebLogic) thread pool there is little you can do not to have a long running thread from looking stuck. Using your own thread pool can cause significant performance issues.
If you have processes that take this long, you may want to use JMS or some other queuing system to process them. This will allow you to limit the number of concurrent processes running this slow process. The queue could be processed on a separate JVM with appropriately modified stuck thread times.
If the queries can run in parallel, then it may be possible to queue multiple JMS items. These would be less likely to run long enough to appear stuck.
As designed you will get thread flagged as stuck. This is not necessarily an issue unless you generate too many such threads, or they never complete. It is likely worthwhile examining other options rather than a container for running the process