1

I get the following exception at times:

ERROR : 07.16.2021:0709 (05.988) [[]http-nio-8080-exec-4] ShippingSatelliteForm: /addLeadTimeForShippingBakeries.xhtml, user - The bean encountered a non-application exception; nested exception is: ERROR : 07.16.2021:0709 (05.988) [[]http-nio-8080-exec-4] ShippingSatelliteForm: /addLeadTimeForShippingBakeries.xhtml, user - The bean encountered a non-application exception; nested exception is:  org.hibernate.exception.JDBCConnectionException: could not execute query 

Caused by: com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][4.21.29] A communication error occurred during operations on the connection's underlying socket, socket input stream,  Caused by: com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][4.21.29] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream.  Error location: Reply.fill() - insufficient data (-1).  Message: Insufficient data. ERRORCODE=-4499, SQLSTATE=08001

enter image description here

enter image description here

I have deployed the application in Azure Kubernetes and DB2 is in on-premises - is this happening due to different networks?

One Developer
  • 99
  • 5
  • 43
  • 103
  • 1
    Some invenstigation needed at your site. Check the Db2-server diagnostics at a time just before this exception. Check the HA configuration details. Get some skilled problem determination people to examine the configuration and diagnostics. This is not programming, it is troubleshooting. – mao Jul 16 '21 at 10:57
  • As @mao already stated, it's probably a network/configuration problem. You should check this stackoverflow [question](https://stackoverflow.com/questions/57830531/using-a-remote-database-as-spring-boot-datasource) and this IBM [FAQ](https://www.ibm.com/support/pages/faq-jdbc-errorcode-4499-connectivity) page. – Mohamed AMAZIRH Jul 26 '21 at 11:36
  • I was working with the network and DB2 team and we could not find any network issues, @mao. we believe that this is an application issue and needs to be addressed. let me know what are the details are needed? – One Developer Jul 26 '21 at 14:49
  • What is the HA configuration? Why are you using a GA version of db2jcc4.jar (instead of the 4.25.25 version)? What is the Db2-server platform (z/os, i-series, linux/unix/windows)? What is the Db2-server version? What events on the Db2-server correlate with timestamps of the symptom seen at the client? – mao Jul 26 '21 at 14:54
  • Can you show us your datasource properties (anonymised of course). The driver-class-name and jdbc-url. – guicey Jul 30 '21 at 07:59

2 Answers2

1

Guessing here, but I would try to add hibernate.c3p0.max_idle_time=300 to have the connection pool recycle connections every 5th minute. This prevents connections from living long enough for someone else (database, firewall etc) to decide to kill it...

Per Huss
  • 4,755
  • 12
  • 29
1

Try testing whether you can still use an idle connection after:

  • 15 seconds
  • 30 seconds
  • 60 seconds

etc.

Most probably you use some kind of NAT-routing, virtual (overlay) network, load-balancer etc. that removes idle connections to avoid running out of memory.

Connection Pools are important to achieve good performance if you run many queries per second, but and if you don't need the connection for many seconds you can either:

  • close the connection
  • retest whether it still is valid
  • configure TCP Keep-Alive (on server or client side)

Default TCP Keep-Alive settings depend on OS configuration and usually require both enabling and setting the correct frequency because the default frequency is usually to late to avoid a timeout. Setting these from Java has only recently become practical and is probably not yet support by the DB2 driver.

See: How to set socket option (TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL) in java or netty?

However your application should be prepared for all kinds of trouble because of: https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing so you may want to add some kind of retry logic to take care of any kind of network issues that may arise now or in the future.

JohannesB
  • 2,214
  • 1
  • 11
  • 18