gpt4 book ai didi

mysql - 连接到 google Cloud SQL 时,AppEngine 中有时会发生通信链接故障错误

转载 作者:行者123 更新时间:2023-11-30 21:50:21 26 4
gpt4 key购买 nike

我从 1 年开始就在 google App Engine 中发布了一个后端项目,一切看起来都很好,1 周前,在 Cloud SQL 中执行 JPA 选择查询时,这个异常有时(不总是)开始抛出日志,有时查询是刚刚成功返回结果:

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 309,979 milliseconds ago. The last packet sent successfully to the server was 309,981 milliseconds ago.
Error Code: 0
Call: SELECT ID, created_time, CURRENCY, IP, NAME FROM country_table Query: ReadAllQuery(name="Country.findAll" referenceClass=Country sql="SELECT ID, created_time, CURRENCY, IP, NAME FROM country_table")

有时这个异常会阻止一些查询的执行:

The last packet successfully received from the server was 219,443 milliseconds ago. The last packet sent successfully to the server was 219,446 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:44) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117) at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3851) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2471) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2739) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2149) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2313) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1007) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:642) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558) at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2002) at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570) at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:250)

最佳答案

这是因为MySQL关闭了连接。

可能 JPA 会自动重新连接到数据库。如果交易结果正确,您可以忽略此消息。

或者您可以在开发人员控制台上使用 interactive_timeoutwait_timeout 延长计时器直到连接关闭。这可以减少消息。

关于mysql - 连接到 google Cloud SQL 时,AppEngine 中有时会发生通信链接故障错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47564369/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com