线上问题:多实例引发的Read timed out 服务器出错

现象:页面上偶尔能查出数据,大多数时候转圈圈。

看日志,第一个实例是正常的,第二个实例报错:

2023-09-18 02:02:26.428  WARN 7 --- [MessageBroker-1] c.baomidou.mybatisplus.mapper.SqlHelper  : Warn: execute Method There are  2 results.
2023-09-18 02:02:36.438 ERROR 7 --- [MessageBroker-1] com.alibaba.druid.pool.DruidDataSource   : {conn-10012} discard
org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:383) ~[postgresql-42.5.0.jar!/:42.5.0]
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:316) ~[postgresql-42.5.0.jar!/:42.5.0]
        at org.postgresql.jdbc.PgConnection.executeTransactionCommand(PgConnection.java:879) ~[postgresql-42.5.0.jar!/:42.5.0]
        at org.postgresql.jdbc.PgConnection.commit(PgConnection.java:901) ~[postgresql-42.5.0.jar!/:42.5.0]
        at com.alibaba.druid.filter.FilterChainImpl.connection_commit(FilterChainImpl.java:161) ~[druid-1.2.16.jar!/:na]
        at com.alibaba.druid.filter.FilterAdapter.connection_commit(FilterAdapter.java:759) ~[druid-1.2.16.jar!/:na]
        at com.alibaba.druid.filter.logging.LogFilter.connection_commit(LogFilter.java:456) ~[druid-1.2.16.jar!/:na]
        at com.alibaba.druid.filter.FilterChainImpl.connection_commit(FilterChainImpl.java:156) ~[druid-1.2.16.jar!/:na]
        at com.alibaba.druid.filter.stat.StatFilter.connection_commit(StatFilter.java:281) ~[druid-1.2.16.jar!/:na]
        at com.alibaba.druid.filter.FilterChainImpl.connection_commit(FilterChainImpl.java:156) ~[druid-1.2.16.jar!/:na]
        at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.commit(ConnectionProxyImpl.java:107) ~[druid-1.2.16.jar!/:na]
        at com.alibaba.druid.pool.DruidPooledConnection.commit(DruidPooledConnection.java:767) ~[druid-1.2.16.jar!/:na]
        at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:333) [spring-jdbc-5.3.26.jar!/:5.3.26]
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743) [spring-tx-5.3.26.jar!/:5.3.26]
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) [spring-tx-5.3.26.jar!/:5.3.26]
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654) [spring-tx-5.3.26.jar!/:5.3.26]
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407) [spring-tx-5.3.26.jar!/:5.3.26]
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) [spring-tx-5.3.26.jar!/:5.3.26]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.3.26.jar!/:5.3.26]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) [spring-aop-5.3.26.jar!/:5.3.26]
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) [spring-aop-5.3.26.jar!/:5.3.26]
        at com.cloud.service.pro.impl.LeaveDutyServiceImpl$$EnhancerBySpringCGLIB$$caca7360.updateById() [classes!/:1.0-SNAPSHOT]
        at com.cloud.controller.pro.DataScheduler.lambda$syncLeaveDuty$5(DataScheduler.java:336) [classes!/:1.0-SNAPSHOT]
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[na:1.8.0_212]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[na:1.8.0_212]
        at com.cloud.controller.pro.DataScheduler.syncLeaveDuty(DataScheduler.java:327) [classes!/:1.0-SNAPSHOT]
        at com.cloud.controller.pro.DataScheduler.leaveDutyNoAreaJob(DataScheduler.java:286) [classes!/:1.0-SNAPSHOT]

数据库报出来的错误,这才想起,服务里面定时任务有定时更新的功能,同时更新一个表可不得timed out 吗?

结论:多实例的的定时任务要改造成xxljob才行。

你可能感兴趣的:(服务器,运维,java)