Closed pfeimich closed 2 years ago
@pfeimich Thank you for creating this issue!
I tried to reproduce your problem but the reporting service worked on my machine even after restarting the postgres service.
jasper-reporting-service
Version: master branch
application.properties:
# Datasource
spring.datasource0.url=jdbc:postgresql://localhost/jasper_test
spring.datasource0.username=****
spring.datasource0.password=****
spring.datasource0.driver-class-name=org.postgresql.Driver
# Custom Parameters
reports.directory=demo/reports/
reports.locale=de_CH
Steps I made to reproduce the problem:
@HusseinKabbout thanks for your answer. Not so here. After restarting postgres service we have the error
2020-03-19 14:01:05.143 WARN 1 --- [nio-8080-exec-7] org.postgresql.jdbc.PgConnection : Validating connection.
org.postgresql.util.PSQLException: FATAL: terminating connection due to administrator command
But we are running v2.0.9 from Sourcepole gitlab and this seems to be a little bit different from this master version here. Our application.properties
spring.h2.console.enabled=false
# Datasource
spring.datasource0.url=jdbc:postgresql://****/***?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
spring.datasource0.username=*****
spring.datasource0.password=******
spring.datasource0.driver-class-name=org.postgresql.Driver
# Custom Parameters
reports.directory=/reports/
reports.locale=de_CH
I have tested it again with the version you use. This time I also got the same error message, but the service still delivered the demo report. The service kind of ignores the exception and just creates a new connection if he needs it. @pfeimich Do the reports not work at all?
Yes with the Postgres Connection Reports I determinded nearly the same behaviour. But for some reports we have an SQL Server Connection and this report doesn't work at all after the reboot of the DB Server.
Since it does still not work, some thoughts: The connections are never returned to the pool. When requesting a report, the connections are created from the datasources once. The connections will be passed to the ModelAndView object which is responsible for creating the PDF. But that's it. Who should be responsible for returning the connection to the pool?
If the application keeps the connection endlessly and the database server will be restarted, the connection will not work anymore. And I don't think that - out of the box - the application will request a new connection from the pool.
When using logging.level.com.zaxxer.hikari=debug
I see that there is one connection active. When closing the connection (dataConnX.close()
) after the PDF creation, there is no active connection.
@HusseinKabbout What do you think?
If the application keeps the connection endlessly and the database server will be restarted, the connection will not work anymore. And I don't think that - out of the box - the application will request a new connection from the pool.
The funny thing is that this only happens with SQL Server
and not with postgres
. With postgres
even if you restart the server, the application will automatically reconnect.
Just to be sure, you already tried setting
testOnBorrow=true
SELECT 1
in the application.properties
file?
testOnBorrow
is a tomcat pooling option. Hikari doesn't know it. We use connection-test-query=SELECT 1
. But I think Hikari will validate the connection with this test query before giving the connection to the application. Since the application (= jasper server) never closes (= returning the connection to the pool) the connection, the test query has not any impact. And a connection outside the pool is never closed by the pool itself.
After losing a DB connection due to reboot of the DB Server jasper-reporting-service does not automatically reconnect the DB connection