逃课的手套 · 沈阳市大东区人民政府关于印发《大东区支持氢能 ...· 2 月前 · |
追风的显示器 · 龙珠Z爆裂大战 基础篇(1) 顺序 - 哔哩哔哩· 4 月前 · |
彷徨的匕首 · 信用体系建设助力家政服务行业高质量发展地方实践· 5 月前 · |
魁梧的茴香 · 烟火气,生活最大的底气! - 脉脉· 1 年前 · |
玩滑板的牛肉面 · Idol天堂漫画小说全文阅读宿醉醒来,29岁 ...· 1 年前 · |
我遇到了这个问题,一天后,它碰巧失去了与数据库的连接。经过一些研究,我添加了这些属性(我了解Spring使用HikariPool作为默认数据源)。
spring.datasource.hikari.username=***
spring.datasource.hikari.password=***
spring.datasource.hikari.connection-timeout=3000
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.connection-init-sql=SELECT 1
spring.datasource.hikari.connection-test-query=SELECT 1
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.validation-timeout=5000
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.leak-detection-threshold=45000
spring.datasource.platform=mysql
spring.jpa.hibernate.ddl-auto=update
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.useServerPrepStmts=true
在 上运行 显示处理器列表,将给出我的应用程序创建的10个休眠进程。
这是我从Spring得到的错误
Feb 01 09:46:21 movxx java[7550]: 2021-02-01 09:46:21.107 INFO 7550 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 69 total, 0 closed abnormally (0 connect failure, 0 send limit, 10 transport error)], stompSubProtocol[processed CONNECT(36)-CONNECTED(36)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 639], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 108], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 2, completed tasks = 96783]
Feb 01 10:16:21 movxx java[7550]: 2021-02-01 10:16:21.108 INFO 7550 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 69 total, 0 closed abnormally (0 connect failure, 0 send limit, 10 transport error)], stompSubProtocol[processed CONNECT(36)-CONNECTED(36)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 639], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 108], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 2, completed tasks = 97144]
Feb 01 10:46:21 movxx java[7550]: 2021-02-01 10:46:21.109 INFO 7550 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 69 total, 0 closed abnormally (0 connect failure, 0 send limit, 10 transport error)], stompSubProtocol[processed CONNECT(36)-CONNECTED(36)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 639], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 108], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 2, completed tasks = 97505]
Feb 01 11:16:21 movxx java[7550]: 2021-02-01 11:16:21.111 INFO 7550 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 69 total, 0 closed abnormally (0 connect failure, 0 send limit, 10 transport error)], stompSubProtocol[processed CONNECT(36)-CONNECTED(36)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 639], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 108], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 2, completed tasks = 97866]
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.090 WARN 7550 --- [io-5000-exec-10] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 08001
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.091 ERROR 7550 --- [io-5000-exec-10]
o.h.engine.jdbc.spi.SqlExceptionHelper : HikariPool-1 - Connection is not available, request timed out after 3000ms.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.091 ERROR 7550 --- [io-5000-exec-10] o.h.engine.jdbc.spi.SqlExceptionHelper : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.091 WARN 7550 --- [nio-5000-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 08001
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.092 ERROR 7550 --- [nio-5000-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper : HikariPool-1 - Connection is not available, request timed out after 3001ms.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.092 ERROR 7550 --- [nio-5000-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.091 WARN 7550 --- [nio-5000-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 08001
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.093 ERROR 7550 --- [nio-5000-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : HikariPool-1 - Connection is not available, request timed out after 3000ms.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.094 ERROR 7550 --- [nio-5000-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.091 WARN 7550 --- [nio-5000-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 08001
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.095 ERROR 7550 --- [nio-5000-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper : HikariPool-1 - Connection is not available, request timed out after 3000ms.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.095 ERROR 7550 --- [nio-5000-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Feb 01 11:24:19 movxx java[7550]: 2021-02-01 11:24:19.173 ERROR 7550 --- [nio-5000-exec-5] c.p.S.security.jwt.AuthTokenFilter : Cannot set user authentication: {}
Feb 01 11:24:19 movxx java[7550]: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
Feb 01 11:24:19 movxx java[7550]: at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:448) ~[spring-orm-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
然而,奇怪的是,如果我杀死其中一个进程,后端就会重新连接,一切都会正常工作。
后端/前端在这段时间内没有使用(或者我连接了2-3次查看它是否还在工作),但是没有高流量或数据库负载。
我不知道下一步该做什么。
后端: Spring数据库: MySQL
编辑:这可能是因为MySQL
wait_timeout
,因为它有默认值(8h)吗?把它设置为比hikari的最大寿命多一分钟更好吗?
Edit2:将数据库
wait_timeout
更改为31分钟,到目前为止,连接仍然有效。这可能是问题所在吗?
另一个更新:后端似乎没有响应一个小时(我不明白,也许我有问题,我的互联网连接),而日志显示什么都没有。这个问题自己解决了。
然而,我发现这个错误出现在连接问题发生前1h,我有一种方法可以在凌晨1点从数据库中删除一些条目。
Feb 07 00:59:09 movxx java[133298]: 2021-02-07 00:59:09.832 DEBUG 133298 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Pool stats (total=10, active=0, idle=10, waiting=0)
Feb 07 00:59:09 movxx java[133298]: 2021-02-07 00:59:09.844 DEBUG 133298 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Fill pool skipped, pool is at sufficient level.
Feb 07 00:59:39 movxx java[133298]: 2021-02-07 00:59:39.871 DEBUG 133298 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Pool stats (total=10, active=0, idle=10, waiting=0)
Feb 07 00:59:40 movxx java[133298]: 2021-02-07 00:59:39.885 DEBUG 133298 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Fill pool skipped, pool is at sufficient level.
Feb 07 01:00:02 movxx java[133298]: 2021-02-07 01:00:02.829 ERROR 133298 --- [MessageBroker-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task
Feb 07 01:00:02 movxx java[133298]: org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call
Feb 07 01:00:02 movxx java[133298]: at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:403) ~[spring-orm-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:257) ~[spring-orm-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:528) ~[spring-orm-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61) ~[spring-tx-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242) ~[spring-tx-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153) ~[spring-tx-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) ~[spring-data-jpa-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at com.sun.proxy.$Proxy178.deleteAllByDateBefore(Unknown Source) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at com.sun.proxy.$Proxy142.deleteAllByDateBefore(Unknown Source) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at com.project.SpringREST.security.ScheduleDeletions.deleteOldNotifications(ScheduleDeletions.java:25) ~[classes!/:0.0.1-SNAPSHOT]
Feb 07 01:00:02 movxx java[133298]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: Caused by: javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call
Feb 07 01:00:02 movxx java[133298]: at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298) ~[spring-orm-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at com.sun.proxy.$Proxy130.remove(Unknown Source) ~[na:na]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.jpa.repository.query.JpaQueryExecution$DeleteExecution.doExecute(JpaQueryExecution.java:274) ~[spring-data-jpa-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) ~[spring-data-jpa-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) ~[spring-data-jpa-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) ~[spring-data-jpa-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) ~[spring-data-commons-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) ~[spring-data-commons-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) ~[spring-data-commons-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) ~[spring-tx-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) ~[spring-tx-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
Feb 07 01:00:02 movxx java[133298]: ... 28 common frames omitted
.... HikariPool logs..
Feb 07 01:17:48 movxx java[133298]: 2021-02-07 01:17:45.800 ERROR 133298 --- [nio-5000-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://www.moviark.com/notifications/277/mhyg3p2g/xhr_streaming?t=1612660664363; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to open session; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to write SockJsFrame content='o'; nested exception is org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe] with root cause
Feb 07 01:17:48 movxx java[133298]: java.io.IOException: Broken pipe
Feb 07 01:17:48 movxx java[133298]: at java.base/sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:na]
Feb 07 01:17:48 movxx java[133298]: at java.base/sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:62) ~[na:na]
Feb 07 01:17:48 movxx java[133298]: at java.base/sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:113) ~[na:na]
Feb 07 01:17:48 movxx java[133298]: at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:79) ~[na:na]
Feb 07 01:17:48 movxx java[133298]: at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:50) ~[na:na]
Feb 07 01:17:48 movxx java[133298]: at java.base/sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:484) ~[na:na]
Edit3: MySQL没有通过SSL与后端连接,因此没有更多的公钥检索错误(最安全的选项),但是现在我在随机时间得到了这个错误,后端重新启动,问题就消失了。这可能是因为CPU /低内存的高负载吗?
Feb 09 20:57:28 movxx java[24771]: 2021-02-09 20:57:27.647 DEBUG 24771 --- [io-5000-exec-12] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Timeout failure stats (total=10, active=10, idle=0, waiting=0)
Feb 09 20:57:29 movxx java[24771]: 2021-02-09 20:57:29.815 DEBUG 24771 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Pool stats (total=10, active=10, idle=0, waiting=0)
Feb 09 20:57:29 movxx java[24771]: 2021-02-09 20:57:29.822 DEBUG 24771 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Fill pool skipped, pool is at sufficient level.
Feb 09 20:57:31 movxx java[24771]: 2021-02-09 20:57:31.533 WARN 24771 --- [io-5000-exec-12] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: null
Feb 09 20:57:31 movxx java[24771]: 2021-02-09 20:57:31.565 ERROR 24771 --- [io-5000-exec-12] o.h.engine.jdbc.spi.SqlExceptionHelper : HikariPool-1 - Connection is not available, request timed out after 5956ms.
Feb 09 20:57:34 movxx java[24771]: 2021-02-09 20:57:34.605 ERROR 24771 --- [io-5000-exec-12] c.p.S.security.jwt.AuthTokenFilter : Cannot set user authentication: {}
Feb 09 20:57:34 movxx java[24771]: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction;
nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
这就是ScheduleDeletions的样子
@Configuration
@EnableAsync
@EnableScheduling
public class ScheduleDeletions {
@Autowired
NotificationsRepository notificationsRepository;
@Scheduled(cron = "0 0 1 * * ?")
public void deleteOldNotifications() {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(new Date().getTime());
cal.add(Calendar.DATE, -7);
notificationsRepository.deleteAllByDateBefore(cal.getTime());
}
发布于 2021-02-09 05:10:27
由于以下错误出现在错误日志中
com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not allowed
应该尝试将
allowPublicKeyRetrieval=true
添加到中。就像这样:
jdbc:mysql://HOST:PORT/DBNAME?allowPublicKeyRetrieval=true
发布于 2021-02-17 11:44:24
我解决了问题。
对于公钥检索,我选择使用SSL作为数据库连接,并遵循 本教程 。
现在关于主要的失败,我是因为ScheduledDeletions类。我用三个步骤解决了这个问题。我将在代码中添加数字,然后像这样解释它。
@Configuration
@EnableAsync
@EnableScheduling
@EnableTransactionManagement [1]
public class ScheduleDeletions {
@Autowired
NotificationsRepository notificationsRepository;
@Scheduled(cron = "0 0 0 * * ?")
@Transactional [2]
public void deleteOldNotifications() {
System.out.println("Running scheduled deletion: " + notificationsRepository.count());
final Calendar cal = Calendar.getInstance();
追风的显示器 · 龙珠Z爆裂大战 基础篇(1) 顺序 - 哔哩哔哩 4 月前 |
彷徨的匕首 · 信用体系建设助力家政服务行业高质量发展地方实践 5 月前 |
魁梧的茴香 · 烟火气,生活最大的底气! - 脉脉 1 年前 |