Hi i have an Transactional annotated service function which makes a call to an external rest Api which sometimes fast and somtimes takes about 10 secs.
Hi,我有一个事务性的带注释的服务功能,它可以调用一个外部rest Api,它有时快速,有时大约需要10秒。
When the api returns fast everything works, when it takes too long hibernate gives me this exception:
当api快速返回时,一切都会正常工作,当它占用了太多的hibernate时间时,我就有了这个例外:
http-bio-8080-exec-5 03/06/2014 16:05:59,346 | WARN | org.hibernate.engine.jdbc.spi.SqlExceptionHelper | logExceptions | SQL Error: 0, SQLState: 08006
http-bio-8080-exec-5 03/06/2014 16:05:59,351 | ERROR | org.hibernate.engine.jdbc.spi.SqlExceptionHelper | logExceptions | An I/O error occured while sending to the backend.
http-bio-8080-exec-5 03/06/2014 16:05:59,353 | WARN | com.mchange.v2.c3p0.impl.NewPooledConnection | handleThrowable | [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
http-bio-8080-exec-5 03/06/2014 16:05:59,354 | WARN | com.mchange.v2.c3p0.impl.NewPooledConnection | handleThrowable | [c3p0] Another error has occurred [ org.postgresql.util.PSQLException: This connection has been closed. ] which will not be reported to listeners!
org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:714)
at org.postgresql.jdbc2.AbstractJdbc2Connection.rollback(AbstractJdbc2Connection.java:731)
at com.mchange.v2.c3p0.impl.NewProxyConnection.rollback(NewProxyConnection.java:860)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doRollback(JdbcTransaction.java:163)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.rollback(AbstractTransactionImpl.java:209)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doRollback(HibernateTransactionManager.java:574)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:846)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:823)
at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:493)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:264)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
the postgres server logs this
postgres服务器对此进行日志记录
2014-06-03 16:04:40 CEST LOG: unvollständige Message vom Client
unvollständige Message vom Client ~~ incomplete message from client
unvollstA¤ndige消息客户端~ ~不完整的消息从客户端生效
so i assume there is any timeout... but i dont know where, my hibernate config:
所以我假设有任何超时…但是我不知道在哪里,我的hibernate配置:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- Connection properties -->
<property name="driverClass" value="org.postgresql.Driver" />
<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/dbname" />
<property name="user" value="postgres" />
<property name="password" value="xxx" />
<!-- Pool properties -->
<property name="numHelperThreads" value="10" />
<property name="acquireIncrement" value="3" />
<property name="initialPoolSize" value="5" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxStatements" value="50" />
<property name="idleConnectionTestPeriod" value="300000" />
<property name="loginTimeout" value="300" />
</bean>
<property name="hibernateProperties">
<value>
hibernate.hbm2ddl.auto=update
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.bytecode.use_reflection_optimizer=false
hibernate.max_fetch_depth=0
</value>
</property>
1 个解决方案
#1
3
the problem was this line
问题是这条线
Restrictions.in("id", hugeidlist)
hugeidlist came from the external api and contained over 100.000 entries, which generated a too long query, i've splitted the list now
hugeidlist来自外部api,包含超过100.000个条目,这产生了一个太长的查询,我现在将列表拆分了
#1
3
the problem was this line
问题是这条线
Restrictions.in("id", hugeidlist)
hugeidlist came from the external api and contained over 100.000 entries, which generated a too long query, i've splitted the list now
hugeidlist来自外部api,包含超过100.000个条目,这产生了一个太长的查询,我现在将列表拆分了