9

Absolutey stumped on this.

I have two controller integration tests that pass successfully. However, when running in Intellij or via gradle check, the JVM never exits. If I comment out the entire integration tests, the JVM exits cleanly.

When debugging any of the integration tests, I can hit pause and see that there are several threads in different states: WAITING, RUNNING, SLEEPING.

The database used in application.yml is purely an in-memory one:

 url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE

Changing this to file based does not fix the problem. Changing DB_CLOSE_ON_EXIT=TRUE does not help either.

I've tried removing @Rollback and even using @Transactional with a timeout, but that doesn't fix it.

Creating an integration test on a fresh project works with no deadlock/hanging/waiting.

I have moved back through revisions to find the changeset where this behaviour started, but the changes were purely in GSPs, Controllers and an additional assertion & test method in one of the integration tests.

The last lines in the logs are:

INFO org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@73386d72: startup date [Mon May 30 18:48:25 BST 2016]; root of context hierarchy
INFO org.springframework.context.support.DefaultLifecycleProcessor - Stopping beans in phase -2147483648
INFO org.grails.plugins.datasource.TomcatJDBCPoolMBeanExporter - Unregistering JMX-exposed beans on shutdown
INFO org.grails.plugins.datasource.TomcatJDBCPoolMBeanExporter - Unregistering JMX-exposed beans
INFO org.hibernate.tool.hbm2ddl.SchemaExport - HHH000227: Running hbm2ddl schema export
INFO org.hibernate.tool.hbm2ddl.SchemaExport - HHH000230: Schema export complete

I've tried cutting the integration test methods down to one method and the issue still occurs.

The versions I'm using are:

$ ~/apps/grails-3.1.5/bin/grails --version
|Grails Version: 3.1.5
|Groovy Version: 2.4.6
|JVM Version: 1.8.0_92

Windows 10 64bit.

Here's a thread dump.

I have no idea how to debug this further. Any ideas?

16
  • 1
    Did you try with to set DB_CLOSE_ON_EXIT=TRUE on the database url ?
    – Joch
    Commented May 30, 2016 at 19:04
  • Just tried it, doesn't fix it. Thanks though. Post updated.
    – Alex
    Commented May 30, 2016 at 20:30
  • 1
    Don't you have any thread that you didn't stop or set as daemon ? Did the JVM stop when you run integrations tests on a fresh project ?
    – Joch
    Commented May 31, 2016 at 17:10
  • I have no threads that I've created myself. The JVM stops when I run on a fresh project. It ran on these integration tests fine but suddenly stopped working. I've tried different transaction manages too (Not @Rollback but with @Transactional and a timeout) but that doesn't help. Totally clueless as to what's causing it. Going to debug with JMX next.
    – Alex
    Commented May 31, 2016 at 17:48
  • Thread dump here: gist.github.com/atc-/e32d6e2211032b21dc50f74037689fa5
    – Alex
    Commented Jul 3, 2016 at 16:40

1 Answer 1

1

I would turn on debug level logging. Also, if you can, I would upgrade grails to something post 3.1.9. (3.1.11 is current as I write this.)

Right around grails v3.1.5 there were configuration inconsistencies between Grails and Hibernate. The grails team was quickly upgrading several interfaces, and they got through it quickly.

The result was that you didn't end up running the configuration that you thought you were. It also affected cache and transaction management.

At the time, I had to create redundant configs to make sure Grails was getting configs at one level, hibernate at another. You don't have to do this anymore, but at the time, I had to use a config like the one listed here.

To find the problem, I turned on debug logging for grails and hibernate and all of my database drivers and waded all of the way through it.

This plugin also helps with the detailed monitoring info:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.