-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Improvement] Mysql 8.x 会话超时,因不再支持 autoReconnect 参数导致超时自动中断 #1512
Comments
看到你使用的是 不过你说的回话超时导致无法写入, 跟之前 issue 区有提到的自动超时没有重连是一个问题么 (参考 #561)? 是说长时间没有跟 mysql 发送请求后链接断开了还是其他意思. ( |
好的,我尝试添加store.connection_detect_interval。 |
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 8,873,663 milliseconds ago. The last packet sent successfully to the server was 8,873,666 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. 具体报错如上,报错信息建议添加'autoReconnect=true' ,但MySQL5开始,不再支持该参数。 |
感谢反馈, 那你有没有去 MySQL 官方 issue 或者类似搜索过, 我想官方取消参数一般会给出新的解决方案吧 |
|
多谢反馈, 那高版自动重连失效之后, 官方也没有给相关的解决方案么, 你后面提到的两个感觉都是用户侧需要做的改动, 还可能带来其他的影响. |
mysql官网给出的理由是:不建议使用autoReconnect选项,因为没有安全的方法重新连接到MySQL服务器,而不冒损坏连接状态或数据库状态信息的风险。相反,使用连接池,这将使您的应用程序能够使用池中的可用连接连接到MySQL服务器。所以autoReconnect功能已弃用。 |
"当前hugegraph中,是否存在连接没有关闭的情况?"——关闭有close方法,就是不知道在哪里调用。可以看一下mysql模块的源码,十个类很简洁。 我对这个问题的看法:没有实现真正的连接池管理,只是在线程与connection之间做了个所谓的session绑定。所以当请求挤压时,线程和连接都会暴增,直到内存爆破。 个人建议:官方团队应当考虑引入第三方成熟的connection pool,而没必要重新发明轮子。 |
你说引入类似 |
这个问题,我这边尝试增加一个自定义的参数,用来对应自己mysql的超时时间 然后改写了BackendSessionPool的几个方法 private BackendSession createNewSession(){ private BackendSession createSessionIfWaitTimeout(BackendSession session) { |
maybe related to: #1672 |
description
使用Mysql作为存储,当连接超过 wait_timeout 时,没法继续写入数据。在Mysq5中,不再支持autoReconnect=true。
当前hugegraph中,是否存在连接没有关闭的情况?
Environment ( 环境信息 - 必填 )
Expected behavior ( 期望表现 )
日常正常使用下,数据能成功呢添加。
Actual behavior ( 实际表现 / 报错)
数据库连接丢失。
异常日志
2021-05-20 00:41:14 93889862 [grizzly-http-server-11] [ERROR] com.baidu.hugegraph.server.RestServer [] - Failed to commit
com.baidu.hugegraph.backend.BackendException: Failed to open transaction
at com.baidu.hugegraph.backend.store.mysql.MysqlStore.beginTx(MysqlStore.java:292) ~[hugegraph-mysql-0.11.2.jar:?]
at com.baidu.hugegraph.backend.tx.AbstractTransaction.commitMutation2Backend(AbstractTransaction.java:304) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at com.baidu.hugegraph.backend.cache.CachedGraphTransaction.commitMutation2Backend(CachedGraphTransaction.java:292) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at com.baidu.hugegraph.backend.tx.IndexableTransaction.commit2Backend(IndexableTransaction.java:57) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at com.baidu.hugegraph.backend.tx.AbstractTransaction.commit(AbstractTransaction.java:223) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at com.baidu.hugegraph.backend.tx.GraphTransaction.commit(GraphTransaction.java:493) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at com.baidu.hugegraph.StandardHugeGraph$Txs.commit(StandardHugeGraph.java:1237) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at com.baidu.hugegraph.StandardHugeGraph$TinkerPopTransaction.doCommit(StandardHugeGraph.java:1117) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.commit(AbstractTransaction.java:104) ~[gremlin-core-3.4.3.jar:3.4.3]
at com.baidu.hugegraph.StandardHugeGraph$TinkerPopTransaction.commit(StandardHugeGraph.java:1083) ~[hugegraph-core-0.11.2.jar:0.11.2.0]
at com.baidu.hugegraph.api.API.commit(API.java:97) [hugegraph-api-0.11.2.jar:0.58.0.0]
at com.baidu.hugegraph.api.graph.VertexAPI.create(VertexAPI.java:94) [hugegraph-api-0.11.2.jar:0.58.0.0]
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common-2.25.1.jar:?]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [jersey-common-2.25.1.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common-2.25.1.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common-2.25.1.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common-2.25.1.jar:?]
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [jersey-common-2.25.1.jar:?]
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:384) [jersey-container-grizzly2-http-2.25.1.jar:?]
at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:200) [grizzly-http-server-2.4.4.jar:2.4.4]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569) [grizzly-framework-2.4.4.jar:2.4.4]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549) [grizzly-framework-2.4.4.jar:2.4.4]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 8,873,663 milliseconds ago. The last packet sent successfully to the server was 8,873,666 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.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:2056) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.baidu.hugegraph.backend.store.mysql.MysqlSessions$Session.begin(MysqlSessions.java:381) ~[hugegraph-mysql-0.11.2.jar:?]
at com.baidu.hugegraph.backend.store.mysql.MysqlStore.beginTx(MysqlStore.java:290) ~[hugegraph-mysql-0.11.2.jar:?]
... 36 more
The text was updated successfully, but these errors were encountered: