1

An exception is thrown at Jdbctemplate.update (unique key violation).

After certain number of these exceptions the hikaripool gets timed out with connection not available (Checked and found out that this error occurs due to pool overload)

Can too many sql exceptions cause a hikariCP timeout?

Marmite Bomber
  • 19,886
  • 4
  • 26
  • 53
Tharusha
  • 635
  • 8
  • 25
  • The short answer is, you have a *maximum number* of connection in the pool - if you try to open more connections, you get this error. – Marmite Bomber Apr 21 '20 at 20:29
  • @MarmiteBomber Yes that is the `hikariCP timeout` reason. My question is if a same sql error occurs too many times will this make too many unattended connections in the pool that puts **hikari** in a timeout – Tharusha Apr 22 '20 at 02:23
  • Which database do you use? – Marmite Bomber Apr 22 '20 at 04:35
  • @MarmiteBomber an oracle DB – Tharusha Apr 22 '20 at 04:37
  • If there are exceptions that return immediately and you close connection in code then there won't be any problem. If you have multiple exceptions due to long timeouts in db, it may cause reaching connection pool limit – Ori Marko Apr 22 '20 at 07:09
  • @user7294900 Here have used spring-boot `JdbcTemplate` . therefor this will close the DB connection from spring container itself. But when using a connection pool the `connection` seems to be sent back to the pool itself. – Tharusha Apr 22 '20 at 07:19
  • you may need to define maxLifeTime, see https://stackoverflow.com/questions/52924419/spring-boot-connection-pool-with-long-running-requests/52941224#52941224 – Ori Marko Apr 22 '20 at 07:26
  • @user7294900 `max-lifeTime:1800000` is already set in it with following hikari properties `Connection-timeout / idle-timeout / maximum-pool-size / minimum-idle / max-lifetime ` – Tharusha Apr 22 '20 at 07:42
  • This would suggest that your connection is not (or not promptly) returned to the pool, or that your connection pool is too small for your actual load. – Mark Rotteveel Apr 22 '20 at 09:41
  • @MarkRotteveel Does after every `jdbctemplate` call will there be a `connection returned to the hicariCP (Even if an exception occurs on JDBC call) ? – Tharusha Apr 22 '20 at 12:28
  • I rarely use `JdbcTemplate`, and if I do it is in a `@Transactional` context. I'm not entirely familiar with how it handles connections. – Mark Rotteveel Apr 22 '20 at 12:59

0 Answers0