当前位置: 首页 > 知识库问答 >
问题:

Spring boot随机崩溃,无错误

皇甫浩壤
2023-03-14

我有一个版本为2.1.2的Spring boot应用程序。释放在日志中没有任何特定信息的情况下,应用程序每个月或几周会崩溃一次。应用程序部署的服务器是CentOS 7版,应用程序由systemd服务启动。

尝试分析堆转储,没有运气,检查了postgres、tomcat等的日志。那里什么都没有。

堆栈跟踪:

INFO ;read-5;523575402;2019-08-07 17:27:24,714;o.s.i.e.EventDrivenConsumer; Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
INFO ;read-5;523575418;2019-08-07 17:27:24,730;o.s.i.c.PublishSubscribeChannel; Channel 'application.errorChannel' has 0 subscriber(s).
INFO ;read-5;523575418;2019-08-07 17:27:24,730;o.s.i.e.EventDrivenConsumer; stopped _org.springframework.integration.errorLogger
INFO ;read-5;523575502;2019-08-07 17:27:24,814;o.s.s.c.ThreadPoolTaskScheduler; Shutting down ExecutorService 'taskScheduler'
INFO ;read-5;523575541;2019-08-07 17:27:24,853;o.s.s.c.ThreadPoolTaskExecutor; Shutting down ExecutorService 'applicationTaskExecutor'
INFO ;read-5;523575572;2019-08-07 17:27:24,884;o.s.o.j.LocalContainerEntityManagerFactoryBean; Closing JPA EntityManagerFactory for persistence unit 'default'
INFO ;read-5;523575596;2019-08-07 17:27:24,908;c.z.h.HikariDataSource; HikariPool-1 - Shutdown initiated...
INFO ;read-5;523575631;2019-08-07 17:27:24,943;c.z.h.HikariDataSource; HikariPool-1 - Shutdown completed.
WARN ;exec-8;523575668;2019-08-07 17:27:24,980;c.z.h.p.ProxyConnection; HikariPool-1 - Connection org.postgresql.jdbc.PgConnection@6ff70ea8 marked as broken because of SQLSTATE(08006), ErrorCode(0)
org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:335)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
        at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:2173)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1936)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1898)

WARN ;exec-6;523575677;2019-08-07 17:27:24,989;c.z.h.p.ProxyConnection; HikariPool-1 - Connection org.postgresql.jdbc.PgConnection@71c6647 marked as broken because of SQLSTATE(08006), ErrorCode(0)
org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:335)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
        at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)

WARN ;exec-8;523575721;2019-08-07 17:27:25,033;o.h.e.j.s.SqlExceptionHelper; SQL Error: 0, SQLState: 08006
WARN ;exec-6;523575721;2019-08-07 17:27:25,033;o.h.e.j.s.SqlExceptionHelper; SQL Error: 0, SQLState: 08006
ERROR;exec-8;523575721;2019-08-07 17:27:25,033;o.h.e.j.s.SqlExceptionHelper; An I/O error occurred while sending to the backend.
ERROR;exec-6;523575721;2019-08-07 17:27:25,033;o.h.e.j.s.SqlExceptionHelper; An I/O error occurred while sending to the backend.
INFO ;exec-6;523575885;2019-08-07 17:27:25,197;o.h.e.i.DefaultLoadEventListener; HHH000327: Error performing load command : org.hibernate.exception.JDBCConnectionException: could not extract ResultSet
org.hibernate.exception.JDBCConnectionException: could not extract ResultSet
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:115)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)

有人知道我该怎么做吗?上次坠机是在那之前的3、4周。

共有1个答案

韦晟睿
2023-03-14

当数据库连接丢失时,就会发生这种类型的错误,而这种情况的发生又有很多原因,最简单的原因是在系统更新后或作为计划操作的一部分重新启动数据库连接。

HikariCP应该能够根据以下链接进行恢复(前提是您的HikariCP版本足够新):

https://github.com/brettwooldridge/HikariCP/wiki/Rapid-Recovery

您可能需要在池中配置一些属性。此处提供了完整的房产列表:

https://github.com/brettwooldridge/HikariCP

我建议您在HikariCP中配置以下内容:

  • ConnectionTestQuery:将定期测试连接,删除死连接。将其与PostgreSQL连接字符串中的ocketTimeout结合使用
  • 泄漏检测阈值:将有助于解决连接泄漏的应用程序
 类似资料:
  • 我正在我的应用程序中使用CameraX API。我已经将预览用例和ImageAnalysis用例绑定到活动生命周期,如 该应用程序大部分时间都可以工作,但会随机崩溃以下日志 2020-01-17 11:24:47.411 6581-6614/com。我的应用程序D/摄像头:重置捕获会话 2020-01-17 11:24:47.411 6581-6614/com.my.appD/相机:关闭状态下的释

  • 我使用CameraX用例在屏幕上显示来自摄像头的图像,同时对其执行对象检测。下面是与CameraX相关的代码,位于我的主要活动的onCreate()函数中。 尽管如此,我在一些(比如说1/5)应用程序初始化时遇到了一个错误,在工作和非工作情况之间没有任何代码或二进制修改: 如果我尝试不访问previewView.display以避免崩溃,我只是得到空裁剪的图像,直到我重新启动应用程序。 它似乎与视

  • 有人尝试过新的火力点坠毁报告吗?

  • 我们正在调查另一个团队开发的一个应用程序,该应用程序在Android上与HereMaps(此处为SDK导航版,)相关的本机崩溃,其stacktrace如下: 编辑: 在代码中进行了一些重构和清理操作之后,我们已经达到了一个干净的状态,在这个状态下,我们确信没有任何泄漏;我们已经用LeakCanary调查并移除了所有这些,但本地崩溃仍然存在。 因此,我们试图回到basis,从github克隆了HER

  • 我在x64 Windows 10 pro上)我下载了最新版本的JDK和Android Studio,想学习如何构建Android应用程序,直到安装和管理SDK和AVD一切正常,我创建了一个新的Hello World项目,它开始下载一些东西,然后突然崩溃,现在当我启动Android Studio时,它正常打开,但在完成文件索引时崩溃,没有错误消息,它只是关闭。我试着以管理员的身份运行,创建了一个新的

  • 根据本教程,我正在将Fabric crashlytics集成到android react本机应用程序中。但是在使用安装Fabric软件包后,我尝试使用为应用程序添加午餐,但出现以下错误: 配置项目': react-nily-结构'时出现问题。 无法解析配置的所有文件: react-nate-结构: classpath。 找不到lint gradle api。jar(com.android.tool