Steve Wall
Steve Wall

Reputation: 1932

Grails Quartz Plugin Freezes on the 8th execution

Environment: Grails 2.0.3, Quartz plugin 1.0-RC2

I have a simple quartz job that reads a value from the database. On the 8th execution, the Job freezes while reading from the database. There is also a web page that retrieves the value from the DB. Once the Job gets into the waiting state, attempting to read the value through the web page also freezes.

Upvotes: 2

Views: 670

Answers (3)

wholenewstrain
wholenewstrain

Reputation: 319

I'm seeing the same thing with Quartz plugin version 1.0.1. On the 8th execution both the Job and Tomcat workers freeze. Used withSession and called Hibernate session.disconnect() in the finally {} block of the job. That did the trick.

def execute() {
   def hsession
   try {
     DomainObject.withSession { ses ->
       hsession = ses

       ....
     }
   } catch(Exception e) {
      //log it etc.
   } finally {
      hsession?.disconnect()
   }
}

Upvotes: 0

Frank Tröger
Frank Tröger

Reputation: 66

Environment: Grails 2.2.0, Quartz plugin 1.0-RC5

I ran into the same problem using quartz-1.0-RC5.

As a workaround I replaced the SessionBinderJobListener class with the one from quartz-0.4.2 (changed only the package to the new one) and the job runs again without any problem. So it looks like the persistenceInterceptor bean does not close the connections or return them to the pool. Maybe there is a problem in org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor with flush and destroy.

If org.quartz.threadPool.threadCount is much less than maxActive in dataSource properties, the problem does not appear (perhaps each job thread already got its connection) or it will only take longer.

Upvotes: 3

Burt Beckwith
Burt Beckwith

Reputation: 75671

The default size of the datasource connection pool is 8, so you're probably not properly closing the connections to return them to the pool.

Upvotes: 2

Related Questions