Last week, a large version of the company’s service was launched. After the launch, the CPU utilization rate of the server frequently occurred for a long time, and the service was unavailable. Because the company’s system is currently running on a single machine, we can only ask the operator to restart Tomcat again and again if there is a problem. We can’t keep the site, so we are in a hurry. The current problem has been solved, here to make a record has been met later problems quickly solved.

1, first determine whether the machine is stuck Java service problem, use the “top” command to see the overall process of the machine

2, Locate abnormal thread, “top-H-P78066”

3, checking their memory command “jmap – histo: live 78066 | wish to view the current thread to the current object of survival, and look at the top of several objects.

4. Download a memory image and run the jmap -dump:live,format=b,file=/data/0223.bin 78066 command. Use mat software, download address: www.eclipse.org/mat/downloa… Download a standalone version.

Finally, according to the stack information in MAT’s report, the code error was located, which was that a query loaded a large query result into the memory, causing the memory to be tight, GC desperately recycling, and finally causing the service to be suspended.

Conclusion: in the code to appear empty condition query will appear problem, generally can be set in the aspect of mybatis interceptors, appears empty condition query will throw an error (www.cnblogs.com/cmfwm/p/802… The druid monitor interface is used to monitor connections to the druid database. The druid monitor interface is used to monitor connections to the druid database. The druid monitor interface is used to monitor connections to the druid database.

References: https://www.cnblogs.com/xiaoL/p/9774095.html https://www.cnblogs.com/AloneSword/p/3821569.htm https://www.cnblogs.com/loong-hon/p/10475143.htmlCopy the code