Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL on cloudfoundry throws PSQLException: FATAL: terminating connection due to administrator command

I have a grails application successfully running in cloudfoundry with H2 as database. I now want to switch to postgresql. Everything works as expected when I run the application locally against postgreSQL.

On the cloudfoundry instance I get an exception during one rather long running analysis, which I perform as a background task (using grails executor plugin). Within this asynchronous task

def future = executorService.submit({
    return analysisService.analyzeProject(model, project)
})

I get the following exception from the database:

2012-11-26 10:27:38,319 [pool-2-thread-1] ERROR interceptor.TransactionInterceptor  - Application exception overridden by rollback exception
org.springframework.dao.DataAccessResourceFailureException: Hibernate operation: could not execute query; SQL [select this_.id as id8_0_, this_.version as version8_0_, this_.language as language8_0_, this_.url as url8_0_ from sonar_adapter_configuration this_]; FATAL: terminating connection due to administrator command; nested exception is org.postgresql.util.PSQLException: FATAL: terminating connection due to administrator command
    at myapp.adapters.sonar.SonarAdapterService.loadSonarConfig(SonarAdapterService.groovy:184)
    at myapp.adapters.sonar.SonarAdapterService.determineArtefactSizes(SonarAdapterService.groovy:145)
    at myapp.project.AnalysisService.analyzeProject(AnalysisService.groovy:46)
    at myapp.project.ProjectController$_analyzeProject_closure2.doCall(ProjectController.groovy:69)
    at grails.plugin.executor.PersistenceContextRunnableWrapper$_run_closure1.doCall(PersistenceContextRunnableWrapper.groovy:34)
    at grails.plugin.executor.PersistenceContextWrapper.wrap(PersistenceContextWrapper.groovy:35)
    at grails.plugin.executor.PersistenceContextRunnableWrapper.run(PersistenceContextRunnableWrapper.groovy:34)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.postgresql.util.PSQLException: FATAL: terminating connection due to administrator command
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
    ... 13 more

Any ideas what might cause this?

like image 624
user1853147 Avatar asked Nov 26 '12 11:11

user1853147


1 Answers

Chances are you are hitting the configured timeout for long running connections (which can't be changed if I'm not mistaken, as it is here to protect the server from ill formed queries that would consume all cpu/io)

What you may want to try is to slice your long running query into smaller queries and sum up the results (if it's a select)

like image 87
ebottard Avatar answered Oct 25 '22 19:10

ebottard