简体   繁体   English

SQLException - 无法检索事务只读状态服务器

[英]SQLException - Could not retrieve transation read-only status server

This question seems to be there all over the internet but without any concrete solution.这个问题似乎在互联网上到处都是,但没有任何具体的解决方案。 I have given up trying various ways.我已经放弃尝试各种方法。

Could anyone help with a more concrete solution or a way to go about knowing more about the underlying issue?任何人都可以帮助提供更具体的解决方案或了解更多潜在问题的方法吗?

A few of the insert queries on a few tables, seem to be failing with the following error:一些表上的一些插入查询似乎失败并出现以下错误:

application-2020-01-30-3.log.gz:org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Could not retrieve transation read-only status server [statement:"INSERT INTO TABLE ({FIELDS}) VALUES({VALUES})", located:"INSERT INTO TABLE ({FIELDS}) VALUES({VALUES})", rewritten:"/* TableDAO.save */ INSERT INTO TABLE ({FIELDS}) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1338)
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.Update.executeAndReturnGeneratedKeys(Update.java:82)
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.sqlobject.UpdateHandler$1.value(UpdateHandler.java:56)
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.sqlobject.UpdateHandler.invoke(UpdateHandler.java:79)
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:224)
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.sqlobject.SqlObject$3.intercept(SqlObject.java:133)
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$dd33673f.save(<generated>)
application-2020-01-30-3.log.gz:    at com.zoomcar.services.inventory.core.impl.UtilizationManagerImpl.calculateUtilization(UtilizationManagerImpl.java:233)
application-2020-01-30-3.log.gz:    at com.zoomcar.services.inventory.scheduler.jobs.UtilizationCalculationJob.execute(UtilizationCalculationJob.java:25)
application-2020-01-30-3.log.gz:    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
application-2020-01-30-3.log.gz:    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
application-2020-01-30-3.log.gz:Caused by: java.sql.SQLException: Could not retrieve transation read-only status server
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:489)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:2610)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:2576)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.PreparedStatement.checkReadOnlySafeStatement(PreparedStatement.java:1082)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.PreparedStatement.execute(PreparedStatement.java:1102)
application-2020-01-30-3.log.gz:    at jdk.internal.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
application-2020-01-30-3.log.gz:    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
application-2020-01-30-3.log.gz:    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
application-2020-01-30-3.log.gz:    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
application-2020-01-30-3.log.gz:    at com.sun.proxy.$Proxy72.execute(Unknown Source)
application-2020-01-30-3.log.gz:    at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1327)
application-2020-01-30-3.log.gz:    ... 10 common frames omitted
application-2020-01-30-3.log.gz:Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 67,698,890 milliseconds ago.  The last packet sent successfully to the server was 67,698,891 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:590)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:57)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
application-2020-01-30-3.log.gz:    at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1936)

Application framework: Dropwizard应用框架:Dropwizard

DB URL used: "jdbc:mysql://{domain-name}:{port}/{DB_NAME}?autoReconnect=true&useSSL=false"使用的数据库 URL:“jdbc:mysql://{domain-name}:{port}/{DB_NAME}?autoReconnect=true&useSSL=false”

DB Driver Class: com.mysql.jdbc.Driver DB驱动类:com.mysql.jdbc.Driver

Application uses Amazon RDS应用程序使用 Amazon RDS

To "know more about the underlying issue" , look at the real error message, ie the last listed "Caused by", not the errors derived from it:“了解更多有关潜在问题的信息” ,请查看真正的错误消息,即最后列出的“由”引起的错误,而不是由此产生的错误:

Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException : The last packet successfully received from the server was 67,698,890 milliseconds ago.引起: com.mysql.cj.jdbc.exceptions.CommunicationsException :从服务器成功接收的最后一个数据包是 67,698,890 毫秒前。 The last packet sent successfully to the server was 67,698,891 milliseconds ago.最后一个成功发送到服务器的数据包是在 67,698,891 毫秒前。 is longer than the server configured value of 'wait_timeout'.比服务器配置的“wait_timeout”值长。 You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.您应该考虑在应用程序中使用之前使连接有效性过期和/或测试连接有效性,增加客户端超时的服务器配置值,或使用连接器/J 连接属性“autoReconnect=true”来避免此问题。

To find "a more concrete solution" , do what the error message said.要找到“更具体的解决方案” ,请按照错误消息的说明进行操作。


Always look at the last listed "Caused by" in a stacktrace when researching the cause of an error.在研究错误原因时,始终查看堆栈跟踪中最后列出的“由”引起的。 This is why it's so important to always list the full stacktrace here on StackOverflow.这就是为什么始终在 StackOverflow 上列出完整的堆栈跟踪如此重要的原因。 Good job doing that.干得好。 🙂 🙂

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM