我有一个在 cloudfoundry 中成功运行的 grails 应用程序,使用 H2 作为数据库。我现在想切换到 postgresql。当我针对 postgreSQL 在本地运行应用程序时,一切都按预期工作。

在 cloudfoundry 实例上,我在一个相当长时间运行的分析中遇到异常,我将其作为后台任务执行(使用 grails 执行程序插件)。在这个异步任务中

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

我从数据库中得到以下异常:

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 

有什么可能导致这种情况的想法吗?

请您参考如下方法:

您很可能会为长时间运行的连接达到配置的超时(如果我没记错的话无法更改,因为它是为了保护服务器免受格式错误的查询的影响,这些查询会消耗所有 cpu/io)

您可能想尝试将长时间运行的查询分割成更小的查询并对结果求和(如果是选择)


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!