17

After we setup PostgreSQL server with SSL certificates we get this error very often. This happens on the flows with a lot of interaction with the database(update a lot of entries/insert)

HikariPool-1 - Connection marked as broken because of SQLSTATE(08006), ErrorCode(0)
j.n.SocketException: Connection reset by peer (Write failed)
    at j.n.SocketOutputStream.socketWrite0(SocketOutputStream.java)
    at j.n.SocketOutputStream.socketWrite(SocketOutputStream.java:110)
    at j.n.SocketOutputStream.write(SocketOutpu`enter code here`tStream.java:150)
    at s.s.s.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:320)
    at s.s.s.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:983)
    ... 63 common frames omitted
Wrapped by: j.n.s.SSLProtocolException: Connection reset by peer (Write failed)
    at s.security.ssl.Alert.createSSLException(Alert.java:126)
    at s.s.s.TransportContext.fatal(TransportContext.java:321)
    at s.s.s.TransportContext.fatal(TransportContext.java:264)
    at s.s.s.TransportContext.fatal(TransportContext.java:259)
    at s.s.s.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:988)
    at j.i.BufferedOutputStream.write(BufferedOutputStream.java:123)
    at j.i.FilterOutputStream.write(FilterOutputStream.java:108)
    at o.p.core.PGStream.send(PGStream.java:252)
    at o.p.c.v.QueryExecutorImpl.sendParse(QueryExecutorImpl.java:1440)
    at o.p.c.v.QueryExecutorImpl.sendOneQuery(QueryExecutorImpl.java:1767)
    at o.p.c.v.QueryExecutorImpl.sendQuery(QueryExecutorImpl.java:1328)
    at o.p.c.v.QueryExecutorImpl.execute(QueryExecutorImpl.java:300)
    ... 56 common frames omitted
Wrapped by: o.p.u.PSQLException: An I/O error occurred while sending to the backend
Cristina
  • 341
  • 2
  • 3
  • 11

3 Answers3

5

I was able to solve this issue by adding below properties:

spring.datasource.test-while-idle=true
spring.datasource.validation-query=SELECT 1;
spring.datasource.time-between-eviction-runs-millis=60000
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.validationTimeout=300000

spring.datasource.remove-abandoned=true
spring.datasource.remove-abandoned-timeout=60

spring.datasource.hikari.connectionTimeout=30000
spring.datasource.hikari.idleTimeout=600000
spring.datasource.hikari.maxLifetime=1800000
PAA
  • 1
  • 46
  • 174
  • 282
4

Fixed the problem by updating jdk version from 11.0.2 to 11.0.5. Related to

Tometzky
  • 22,573
  • 5
  • 59
  • 73
Cristina
  • 341
  • 2
  • 3
  • 11
1

SQLSTATE(08006), ErrorCode(0) :

That indicates that the PostgreSQL server backend is crashing. Specifically, signal 6 (SIGABRT) is triggered by assertion failures, places the code intentionally crashes because something is wrong and it can't continue without risking data corruption.

We faced the same issue in our Production environment and this was due to binding of parameters in the query. Postgresql only allows a max of 32767(short.max_value) for version 7.x

You could try running your query in parts and then using the result. This solved our issue. Hope this helps!!!