MariaDB闲置一段时间后无法工作

时间:2014-11-05 11:19:36

标签: java tomcat7 mariadb

在我的webapp上,我经常遇到以下异常: java.sql.SQLNonTransientConnectionException:无法发送查询:最后一个数据包未完成 它通常在系统闲置很长一段时间后发生。 重启tomcat会暂时解决问题。

我最近在生产服务器上运行了RHEL7(运行tomcat7和mariaDB 5.5)。 在旧服务器上没有发生此错误(使用mySQL运行RHEL5)。 我将java数据库驱动程序从旧服务器上使用的mysql驱动程序更新到最新的稳定mariadb连接器:mariadb-java-client-1.1.7.jar。

如何解决问题或解决方法?

以下是此例外的完整日志:

Lexicon Message: Content.getData Error trying to excute: SELECT * FROM prefixes where prefix ='l' java.sql.SQLNonTransientConnectionException: Could not send query: Last packet not finished at org.mariadb.jdbc.internal.SQLExceptionMapper.get(SQLExceptionMapper.java:136) at org.mariadb.jdbc.internal.SQLExceptionMapper.throwException(SQLExceptionMapper.java:106) at org.mariadb.jdbc.MySQLStatement.executeQueryEpilog(MySQLStatement.java:264) at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:288) at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:338) at snaq.db.CachedStatement.execute(CachedStatement.java:339) at mila.lexicon.dbUtils.Connected.getData(Connected.java:257) at mila.lexicon.dbUtils.Prefixes.get(Prefixes.java:29) at mila.lexicon.analyse.Data.getPrefixes(Data.java:446) at mila.HMM.HMM2Morph.handlePrefixProperNameAnalysis(HMM2Morph.java:1196) at mila.HMM.HMM2Morph.parseXML(HMM2Morph.java:1791) at mila.HMM.HMM2Morph.process(HMM2Morph.java:2337) at org.apache.jsp.processAnalyzerXML_jsp._jspService(processAnalyzerXML_jsp.java:187) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1024) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: org.mariadb.jdbc.internal.common.QueryException: Could not send query: Last packet not finished at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:984) at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:281) ... 31 more Caused by: java.io.IOException: Last packet not finished at org.mariadb.jdbc.internal.common.packet.PacketOutputStream.startPacket(PacketOutputStream.java:38) at org.mariadb.jdbc.internal.common.packet.commands.StreamedQueryPacket.send(StreamedQueryPacket.java:76) at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:982) ... 32 more

1 个答案:

答案 0 :(得分:1)

我们没有足够的信息,但我遇到了与mysql服务器类似的问题。更改my.cnf

中的超时设置后问题得以解决
wait_timeout        = 28800        
interactive_timeout = 28800

28800 secons - 8小时

重新启动服务器以应用更改