I have a simple app which supports just GET & POST using JDBCTemplate, in tomcat configuration (context.xml) is set where it can find the Database like below:
<Resource name="jdbc/MYDB" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/MYDB" factory="org.apache.commons.dbcp.BasicDataSourceFactory"
username="postgres" password="postgres" maxActive="20" maxIdle="10" maxWait="-1"/>
Now the problem is sometime I get the disconnection session in this period of time GET response is not working. The application and the database is deployed on server Redhat if it helps.
Is this a common behavior of the PostgreSQL or is not related at all to DB and it is a tomcat configuration.
this is my web.xml and server.xml (I am using default config)
web.xml
<session-config>
<session-timeout>30</session-timeout>
</session-config>
server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
and this is the postgresql.log
2019-03-25 01:35:07 GMT:???(???):postgres@MYDB:[16745]:LOG: disconnection: session time: 2:11:42.913 user=postgres database=MYDB host=??? port=???
2019-03-25 07:45:21 GMT:???(???):postgres@MYDB:[26489]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 07:45:21 GMT:???(???):postgres@MYDB:[26489]:LOG: disconnection: session time: 0:00:00.011 user=postgres database=MYDB host=??? port=???
2019-03-25 07:45:21 GMT:???(???):postgres@MYDB:[26490]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 09:30:47 GMT:???(???):postgres@MYDB:[28557]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 09:31:04 GMT:???(???):postgres@MYDB:[28573]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 09:57:01 GMT:???(???):postgres@MYDB:[26490]:LOG: disconnection: session time: 2:11:39.674 user=postgres database=MYDB host=??? port=???
2019-03-25 10:57:14 GMT:localhost(43186):postgres@MYDB:[30555]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 10:57:14 GMT:localhost(43187):postgres@MYDB:[30556]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 10:57:14 GMT:localhost(43185):postgres@MYDB:[30554]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 10:57:14 GMT:localhost(43188):postgres@MYDB:[30557]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 10:58:33 GMT:localhost(57025):postgres@MYDB:[25183]:LOG: disconnection: session time: 88:42:29.922 user=postgres database=MYDB host=localhost port=57025
2019-03-25 10:58:33 GMT:localhost(57024):postgres@MYDB:[25182]:LOG: disconnection: session time: 88:42:29.925 user=postgres database=MYDB host=localhost port=57024
2019-03-25 10:58:33 GMT:localhost(57026):postgres@MYDB:[25184]:LOG: disconnection: session time: 88:42:29.920 user=postgres database=MYDB host=localhost port=57026
2019-03-25 11:04:29 GMT:???(???):postgres@MYDB:[30738]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 11:04:29 GMT:???(???):postgres@MYDB:[30738]:LOG: disconnection: session time: 0:00:00.009 user=postgres database=MYDB host=??? port=???
2019-03-25 11:04:29 GMT:???(???):postgres@MYDB:[30739]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 12:57:25 GMT:localhost(44151):postgres@MYDB:[431]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 12:58:33 GMT:localhost(57022):postgres@MYDB:[25180]:LOG: disconnection: session time: 90:42:29.930 user=postgres database=MYDB host=localhost port=57022
2019-03-25 13:10:21 GMT:???(???):postgres@MYDB:[28573]:LOG: disconnection: session time: 3:39:16.743 user=postgres database=MYDB host=??? port=???
2019-03-25 13:15:48 GMT:???(???):postgres@MYDB:[30739]:LOG: disconnection: session time: 2:11:19.065 user=postgres database=MYDB host=??? port=???
2019-03-25 13:24:33 GMT:???(???):postgres@MYDB:[28557]:LOG: disconnection: session time: 3:53:45.926 user=postgres database=MYDB host=??? port=???
2019-03-25 14:00:19 GMT:???(???):postgres@MYDB:[1706]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 14:00:19 GMT:???(???):postgres@MYDB:[1706]:LOG: disconnection: session time: 0:00:00.012 user=postgres database=MYDB host=??? port=???
2019-03-25 14:00:19 GMT:???(???):postgres@MYDB:[1707]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 16:11:40 GMT:???(???):postgres@MYDB:[1707]:LOG: disconnection: session time: 2:11:20.211 user=postgres database=MYDB host=??? port=???
2019-03-25 16:54:26 GMT:???(???):postgres@MYDB:[5047]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 16:54:26 GMT:???(???):postgres@MYDB:[5047]:LOG: disconnection: session time: 0:00:00.010 user=postgres database=MYDB host=??? port=???
2019-03-25 16:54:26 GMT:???(???):postgres@MYDB:[5048]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 16:55:00 GMT:???(???):postgres@MYDB:[5048]:LOG: disconnection: session time: 0:00:34.462 user=postgres database=MYDB host=??? port=???
2019-03-25 16:55:08 GMT:???(???):postgres@MYDB:[5065]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 16:55:08 GMT:???(???):postgres@MYDB:[5065]:LOG: disconnection: session time: 0:00:00.009 user=postgres database=MYDB host=??? port=???
2019-03-25 16:55:08 GMT:???(???):postgres@MYDB:[5066]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 17:34:58 GMT:localhost(46372):postgres@MYDB:[5833]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 17:36:08 GMT:localhost(44151):postgres@MYDB:[431]:LOG: disconnection: session time: 4:38:42.392 user=postgres database=MYDB host=localhost port=44151
2019-03-25 18:41:51 GMT:???(???):postgres@MYDB:[7097]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 18:41:51 GMT:???(???):postgres@MYDB:[7097]:LOG: disconnection: session time: 0:00:00.021 user=postgres database=MYDB host=??? port=???
2019-03-25 18:41:51 GMT:???(???):postgres@MYDB:[7098]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 19:06:26 GMT:???(???):postgres@MYDB:[5066]:LOG: disconnection: session time: 2:11:18.453 user=postgres database=MYDB host=??? port=???
2019-03-25 20:23:12 GMT:???(???):postgres@MYDB:[9039]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 20:23:14 GMT:???(???):postgres@MYDB:[9040]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 20:24:17 GMT:???(???):postgres@MYDB:[9040]:LOG: disconnection: session time: 0:01:03.345 user=postgres database=MYDB host=??? port=???
2019-03-25 20:24:17 GMT:???(???):postgres@MYDB:[9039]:LOG: disconnection: session time: 0:01:04.769 user=postgres database=MYDB host=??? port=???
2019-03-25 20:51:10 GMT:localhost(47943):postgres@MYDB:[9562]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 20:52:13 GMT:localhost(43186):postgres@MYDB:[30555]:LOG: disconnection: session time: 9:54:58.371 user=postgres database=MYDB host=localhost port=43186
2019-03-25 20:56:16 GMT:localhost(47984):postgres@MYDB:[9654]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 20:57:18 GMT:localhost(43187):postgres@MYDB:[30556]:LOG: disconnection: session time: 10:00:03.457 user=postgres database=MYDB host=localhost port=43187
2019-03-25 20:57:25 GMT:localhost(47995):postgres@MYDB:[9676]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 20:58:33 GMT:localhost(47984):postgres@MYDB:[9654]:LOG: disconnection: session time: 0:02:16.288 user=postgres database=MYDB host=localhost port=47984
2019-03-25 21:46:35 GMT:???(???):postgres@MYDB:[10616]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 21:46:35 GMT:???(???):postgres@MYDB:[10616]:LOG: disconnection: session time: 0:00:00.009 user=postgres database=MYDB host=??? port=???
2019-03-25 21:46:35 GMT:???(???):postgres@MYDB:[10617]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 22:02:03 GMT:localhost(48514):postgres@MYDB:[10937]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 22:02:03 GMT:localhost(48513):postgres@MYDB:[10936]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 22:02:04 GMT:localhost(48512):postgres@MYDB:[10935]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 22:03:13 GMT:localhost(57023):postgres@MYDB:[25181]:LOG: disconnection: session time: 99:47:10.079 user=postgres database=MYDB host=localhost port=57023
2019-03-25 22:03:13 GMT:localhost(43185):postgres@MYDB:[30554]:LOG: disconnection: session time: 11:05:58.525 user=postgres database=MYDB host=localhost port=43185
2019-03-25 22:03:18 GMT:localhost(48513):postgres@MYDB:[10936]:LOG: disconnection: session time: 0:01:15.291 user=postgres database=MYDB host=localhost port=48513
2019-03-25 22:15:09 GMT:localhost(48622):postgres@MYDB:[11181]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 22:15:09 GMT:localhost(48623):postgres@MYDB:[11182]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 22:15:09 GMT:localhost(48621):postgres@MYDB:[11180]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 22:16:13 GMT:localhost(47943):postgres@MYDB:[9562]:LOG: disconnection: session time: 1:25:03.165 user=postgres database=MYDB host=localhost port=47943
2019-03-25 22:16:13 GMT:localhost(48512):postgres@MYDB:[10935]:LOG: disconnection: session time: 0:14:10.006 user=postgres database=MYDB host=localhost port=48512
2019-03-25 22:16:13 GMT:localhost(48514):postgres@MYDB:[10937]:LOG: disconnection: session time: 0:14:10.007 user=postgres database=MYDB host=localhost port=48514
2019-03-25 22:53:37 GMT:???(???):postgres@MYDB:[7098]:LOG: disconnection: session time: 4:11:45.432 user=postgres database=MYDB host=??? port=???
2019-03-25 23:23:22 GMT:???(???):postgres@MYDB:[12477]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 23:23:22 GMT:???(???):postgres@MYDB:[12477]:LOG: disconnection: session time: 0:00:00.009 user=postgres database=MYDB host=??? port=???
2019-03-25 23:23:22 GMT:???(???):postgres@MYDB:[12478]:LOG: connection authorized: user=postgres database=MYDB
2019-03-25 23:58:04 GMT:???(???):postgres@MYDB:[10617]:LOG: disconnection: session time: 2:11:28.457 user=postgres database=MYDB host=??? port=???
log_disconnections
). So it looks like tomcat is dropping db connections for some reason.