浪子花梦 2023-05-05 14:15 采纳率: 42.9%
浏览 153

使用 HikariPool数据源,连接postgresql 超时之后,一直连接不上

postgresql 连接超时:Could not open JDBC Connection for transaction; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 10000ms.

img


出现这个问题后,会一直连接不上数据库,重启jar包之后就没事了,之前修改了一下数据源相关的连接数配置,pgsql的最大连接配置设置成了100,没有什么效果。

数据源配置:


hikari:
  auto-commit: false
  connection-timeout: 10000
  idle-timeout: 25000
  login-timeout: 5
  max-lifetime: 30000
  read-only: false
  validation-timeout: 3000
  maximum-pool-size: 100
  minimum-idle: 30
  data-source-properties:
    cachePrepStmts: true
    prepStmtCacheSize: 250
    prepStmtCacheSqlLimit: 2048
    useServerPrepStmts: true
    useLocalSessionState: true
    rewriteBatchedStatements: true
    cacheResultSetMetadata: true
    cacheServerConfiguration: true
    elideSetAutoCommits: true
    maintainTimeStats: false

这个项目每隔20s会执行两三个定时任务,我怀疑是不是定时任务产生的这个问题。

  • 写回答

2条回答 默认 最新

  • 小龙在山东 领域专家: Python技术领域 2023-05-05 14:30
    关注

    是不是连接池中的连接一直被占用,没有被释放。
    可以参考:https://www.cnblogs.com/chengmuyu/p/16512251.html

    评论

报告相同问题?

问题事件

  • 创建了问题 5月5日