Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails Controller / Integration Test succeeds but hangs forever

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?

like image 678
Alex Avatar asked May 30 '16 17:05

Alex


1 Answers

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:

like image 85
fcnorman Avatar answered Oct 23 '22 06:10

fcnorman