2015-08-07 11 views
6

Küçük bir Heroku + Grails + Postreg uygulaması geliştirdim. Kendim çözmüşHeroku Postgres: Bu bağlantı kapatıldı

This connection has been closed.. Stacktrace follows: Heroku/myapp 
- org.postgresql.util.PSQLException: This connection has been closed. Heroku/myapp 
- at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:837) Heroku/myapp 
- at org.postgresql.jdbc2.AbstractJdbc2Connection.getAutoCommit(AbstractJdbc2Connection.java:798) Heroku/myapp 
- at org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2.doCall(GormStaticApi.groovy:102) Heroku/myapp 
- at com.myapp.WorkspaceController.list(WorkspaceController.groovy:18) Heroku/myapp 
- at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198) Heroku/myapp 
- at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) Heroku/myapp 
- at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) Heroku/myapp 
- at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:53) Heroku/myapp 
- at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62) Heroku/myapp 
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) Heroku/myapp 
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) Heroku/myapp 
- at java.lang.Thread.run(Thread.java:745) Heroku/myapp 
- 2015-08-07 15:11:10,685 [http-nio-20850-exec-5] ERROR spi.SqlExceptionHelper - This connection has been closed. Heroku/myapp 
- 2015-08-07 15:11:10,689 [http-nio-20850-exec-5] ERROR spi.SqlExceptionHelper - This connection has been closed. Heroku/myapp 
- 2015-08-07 15:11:10,696 [http-nio-20850-exec-5] ERROR errors.GrailsExceptionResolver - PSQLException occurred when processing request: [GET] /api/users/21/workspaces Heroku/myapp 
- This connection has been closed.. Stacktrace follows: Heroku/myapp 
+0

Veri kaynağı ayarlarınızı grails içine yapıştırabilir misiniz? –

cevap

6

DataSource.groovy bu ekleyerek: Ondan sonra hep olsun, biraz 20 dakika dağıtımdan sonra ince çalışacak

dataSource { 
    pooled = true 
    properties { 
     maxActive = -1 
     minEvictableIdleTimeMillis=1800000 
     timeBetweenEvictionRunsMillis=1800000 
     numTestsPerEvictionRun=3 
     testOnBorrow=true 
     testWhileIdle=true 
     testOnReturn=true 
     validationQuery="SELECT 1" 
    } 
} 
+0

Bu özelliklerden hangisinin gerçekten fark yarattığı hakkında bir fikrin var mı? – Jonik

+1

Bir Spring Boot uygulamasında aynı sorunu yaşadım ([DataSource] kullanarak (https://tomcat.apache.org/tomcat-8.0-doc/api/org/apache/tomcat/jdbc/pool/DataSource.html) Tomcat JDBC) ve ben 'setTestOnBorrow (true) kullanarak çözdüm gibi görünüyor; setTestWhileIdle (doğru); setTestOnReturn (doğru); setValidationQuery ("SELECT 1"); '([javadocs] (https://tomcat.apache.org/tomcat-8.0-doc/api/org/apache/tomcat/jdbc/pool/DataSourceProxy.html#setTestOnBorrow (boole))). Teşekkürler! – Jonik

2

@ Macchiatow cevabı kombinasyonu ve @ Jonik'in yorumu, daha az özellikli çalışmam buydu:

dataSource { 
    pooled = true 
    properties { 
     testOnBorrow = true 
     testWhileIdle = true 
     testOnReturn = true 
     validationQuery = "SELECT 1" 
    } 
    driverClassName = "org.postgresql.Driver" 
    dialect = "..." 
}