String.toUpperCase()上的Java阻塞线程>> [

问题描述 投票:3回答:1
查询Oracle数据库时,其中一个线程的锁超过3秒钟。在访问Oracle数据库时,这会导致许多阻塞的线程,因此,线程数量突然增加,导致应用程序失效。我正在使用Tomcat 8.5,Tomcat连接池,Java8。跟踪阻塞线程:

***"http-nio-80-exec-433" #4207 daemon prio=5 os_prio=0 tid=0x00007fd9d8042000 nid=0x503b runnable [0x00007fd839f04000] java.lang.Thread.State: RUNNABLE at java.util.Hashtable.get(Hashtable.java:363) - locked <0x000000070193caa0> (a java.util.Hashtable) at java.lang.ConditionalSpecialCasing.lookUpTable(ConditionalSpecialCasing.java:151) at java.lang.ConditionalSpecialCasing.toUpperCaseEx(ConditionalSpecialCasing.java:123) at java.lang.String.toUpperCase(String.java:2775) at java.lang.String.toUpperCase(String.java:2833) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1638) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4401) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:4482) - locked <0x000000074cd7d868> (a oracle.jdbc.driver.T4CConnection) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:6272) at sun.reflect.GeneratedMethodAccessor400.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:210) at com.sun.proxy.$Proxy637.executeQuery(Unknown Source) at sun.reflect.GeneratedMethodAccessor400.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) at com.sun.proxy.$Proxy637.executeQuery(Unknown Source) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1953) at org.hibernate.loader.Loader.doQuery(Loader.java:802) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) at org.hibernate.loader.Loader.doList(Loader.java:2533) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276) at org.hibernate.loader.Loader.list(Loader.java:2271)***

这里是10个以上已阻塞线程之一的踪迹

***"http-nio-80-exec-271" #2777 daemon prio=5 os_prio=0 tid=0x00007fd9c8941800 nid=0x19c3 waiting for monitor entry [0x00007fd8356ca000] java.lang.Thread.State: BLOCKED (on object monitor) at java.util.Hashtable.get(Hashtable.java:363) - waiting to lock <0x000000070193caa0> (a java.util.Hashtable) at java.lang.ConditionalSpecialCasing.lookUpTable(ConditionalSpecialCasing.java:151) at java.lang.ConditionalSpecialCasing.toUpperCaseEx(ConditionalSpecialCasing.java:123) at java.lang.String.toUpperCase(String.java:2775) at java.lang.String.toUpperCase(String.java:2833) at oracle.jdbc.driver.CharCommonAccessor.init(CharCommonAccessor.java:164) at oracle.jdbc.driver.VarcharAccessor.<init>(VarcharAccessor.java:88) at oracle.jdbc.driver.T4CVarcharAccessor.<init>(T4CVarcharAccessor.java:108) at oracle.jdbc.driver.T4CTTIdcb.fillupAccessors(T4CTTIdcb.java:431) at oracle.jdbc.driver.T4CTTIdcb.receiveCommon(T4CTTIdcb.java:209) at oracle.jdbc.driver.T4CTTIdcb.receive(T4CTTIdcb.java:145) at oracle.jdbc.driver.T4C8Oall.readDCB(T4C8Oall.java:963) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:447) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:235) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:543) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:239) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:1246) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1500) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1717) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4401) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:4482) - locked <0x000000074d203f60> (a oracle.jdbc.driver.T4CConnection) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:6272) at sun.reflect.GeneratedMethodAccessor400.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:210) at com.sun.proxy.$Proxy637.executeQuery(Unknown Source) at sun.reflect.GeneratedMethodAccessor400.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) at com.sun.proxy.$Proxy637.executeQuery(Unknown Source) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)***

我不知道为什么toUpperCase()会锁定某些东西(据我发现,这是某个Integer对象被锁定了)超过30秒钟,但这每天仍会发生多次。线程转储分析器在转储中未发现任何死锁。 Tomcat池日志查询阻塞线程http-nio-80-exec-433耗时5分钟。

这可能是jvm,内存或其他问题吗?像jdbc驱动程序或连接池配置问题?

查询Oracle数据库时,其中一个线程的锁超过3秒钟。访问Oracle数据库时,这会导致许多阻塞的线程,因此线程数量突然增加,并且...

java multithreading jdbc database-connection blocked-threads
1个回答
0
投票
看来问题与代码无关。我们有10GB大小的catalina.out日志文件,以及4个bash脚本,它们每五分钟分析一次该文件的特定错误,并且由于文件很大,每个这样的分析(主要是tail / wc命令)花费了3-4分钟。我不知道catalina.out是否被锁定,但是“ tail”和“ wc”命令的CPU使用率非常高。内存使用没有明显增加。
© www.soinside.com 2019 - 2024. All rights reserved.