点击菜单偶尔报错com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

Blade 未结 3 2337
niko
niko 剑童 2020-05-18 17:26
悬赏:10

页面上随意点击菜单,偶尔爆出以下错误。


页面上弹出:

image.png


日志上显示:

image.png

页面弹框消失后,后面又能查到数据。


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

工程是bladeX+Sabe V2.5.0版本,在CentOS Linux release 7.6.1810 (Core)使用docker部署,使用的mysql:5.7.30 镜像


3条回答
  • 这报错是数据库连接超时了,不是框架问题。

    0 讨论(1)
  • 2020-05-19 11:52

    org.springframework.dao.RecoverableDataAccessException: PreparedStatementCallback; SQL [select resource_code, scope_column, scope_field, scope_type, scope_value from blade_scope_data where scope_class = ? and id in (select scope_id from blade_role_scope where scope_category = 1 and role_id in (?))]; Communications link failure


    The last packet successfully received from the server was 237,026 milliseconds ago.  The last packet sent successfully to the server was 237,027 milliseconds ago.; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure


    The last packet successfully received from the server was 237,026 milliseconds ago.  The last packet sent successfully to the server was 237,027 milliseconds ago.

    at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:100)

    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)

    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)

    at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443)

    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633)

    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:669)

    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:700)

    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:712)

    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:763)

    at org.springblade.system.feign.DataScopeClient.getDataScopeByMapper(DataScopeClient.java:60)

    at sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:498)

    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)

    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)

    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)

    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:893)

    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:798)

    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)

    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)

    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)

    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:645)

    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)

    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)

    at com.github.xiaoymin.knife4j.spring.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at com.github.xiaoymin.knife4j.spring.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:90)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at org.springblade.core.tool.request.BladeRequestFilter.doFilter(BladeRequestFilter.java:49)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)

    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)

    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)

    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94)

    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)

    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)

    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)

    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at com.alibaba.csp.sentinel.adapter.servlet.CommonFilter.doFilter(CommonFilter.java:110)

    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)

    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

    at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)

    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

    at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)

    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)

    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)

    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)

    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)

    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)

    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)

    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)

    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)

    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)

    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

    at java.lang.Thread.run(Thread.java:748)

    Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure


    The last packet successfully received from the server was 237,026 milliseconds ago.  The last packet sent successfully to the server was 237,027 milliseconds ago.

    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)

    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)

    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)

    at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1003)

    at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227)

    at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:678)

    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617)

    ... 89 more

    Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure


    The last packet successfully received from the server was 237,026 milliseconds ago.  The last packet sent successfully to the server was 237,027 milliseconds ago.

    at sun.reflect.GeneratedConstructorAccessor130.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)

    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)

    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)

    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)

    at com.mysql.cj.protocol.a.NativeProtocol.clearInputStream(NativeProtocol.java:816)

    at com.mysql.cj.protocol.a.NativeProtocol.sendCommand(NativeProtocol.java:631)

    at com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket(NativeProtocol.java:949)

    at com.mysql.cj.NativeSession.execSQL(NativeSession.java:1113)

    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:930)

    ... 93 more

    Caused by: java.io.IOException: Socket is closed

    at com.mysql.cj.protocol.AbstractSocketConnection.getMysqlInput(AbstractSocketConnection.java:72)

    at com.mysql.cj.protocol.a.NativeProtocol.clearInputStream(NativeProtocol.java:812)

    ... 97 more


    0 讨论(0)
  • 2020-05-20 21:19

    我也有这问题,随机弹出这报错,是否要自行配置druid数据库连接池?难道是因为druid空白配置的存活时间比MySQL的默认8小时要长?访问了一个已经被数据库杀掉的连接池?

    0 讨论(1)
提交回复