javamelody / grails-melody-plugin

JavaMelody monitoring plugin for Grails, to monitor application performance
https://plugins.grails.org/plugin/grails-melody-plugin
Apache License 2.0
32 stars 31 forks source link

"Connection is closed" issue when Tomcat recreates connection #52

Closed bassmartin closed 6 years ago

bassmartin commented 6 years ago

After having network issues between my Grails app and the Postgres DB on AWS, JDBC connections needed to be recreated by Tomcat. It did so, but then my app would somewhat end up with connections that are closed when executing transactions afterward.

After a long investigation, the issue was not happening when removing the JavaMelody plugin from my app. So I dug a bit to find what was happening and saw that the SpringDataSourceBeanPostProcessor was proxying three DataSources (dataSourceUnproxied, dataSourceLazy and dataSource).

I tried configuring it to only proxy one of them. By proxying dataSourceUnproxied, JDBC queries are still monitored by JavaMelody and when connections are recreated by Tomcat everything seems to be working as expected.

I suggest we add "dataSourceLazy" and "dataSource" in the excluded list of proxyed datasource in GrailsMelodyPluginGrailsPlugin or at least write some documentation about configuration of the plugin with Tomcat (default Grails configuration).

I have a pull-request with this "fix". Tell me what you think about this issue / fix.

Thanks.

sergiomichels commented 6 years ago

This is not duplicate of #53?

bassmartin commented 6 years ago

Yes it iis

sergiomichels commented 6 years ago

Closing since it's a duplicate issue.