Issue Type: Bug Bug
Affects Versions: 4.1.11, 3.6.7
Assignee: Unassigned
Attachments: console log with sql on.txt, hibernate-hang.jar, show engine innodb status.txt
Components: annotations, core
Created: 23/Apr/13 3:47 PM
Description:

While learning JPA in the context of Hibernate, I adapted the following tutorial to work with Hibernate and MySQL:

http://www.vogella.com/articles/JavaPersistenceAPI/article.html

This worked with a few small changes (see attached 'hibernate-hang.jar' for the resultant Eclipse project), except for one problem: it often hangs when using a Java 1.7 JVM (depending on how I run it – see next paragraph). This seems strange because it always works when run on a Java 1.6 JVM.

When the JUnit test methods are run individually, they all complete successfully using Java 1.6 or 1.7. However, using 1.7, if they are all run in a single invocation (by invoking JUnit on the main JpaTest class), testing usually hangs in the 3rd test method (usually this is checkAvailablePeople() ). I have seen it succeed occasionally, but I don't think I've ever seen it succeed twice in a row.

While it's hung, if I try to access the tables from the mysql command line, as in:

select * from relationsshipdb.person;

It hangs there too.

I enabled sql logging to see what it was doing. Per the attached file ("console log with sql on.txt"), the hang occurs during the following operation:

INFO: HHH000227: Running hbm2ddl schema export
Hibernate:
alter table Person
drop
foreign key FK8E488775B78CE81F

Using 'show engine innodb status;' at the command line (see attached file 'show engine innodb status.txt'), I found that it is waiting for a table metadata lock. So far, the only way I have found to address this hang is to stop the database and then start it again.

To assist in fault isolation I kept the modifications I made as simple as possible and tried varying many different factors including:

  • MySQL version (5.5.30 vs 5.6.10)
  • Hibernate version (3.6.7 Final vs 4.1.11 Final)
  • Upgraded JRE (from 1.7.0_u17 to 1.7.0_u21)
  • Eclipse (from JEE to plain Java version, in case the SE-oriented tutorial I used wasn't compatible with a JEE environment).

but the only thing I've found that doesn't hang is using a 1.6 JVM version (specifically, 1.6.0_45).

Of note:

  • To run the included test case, it's necessary to first create a schema in MySQL called 'relationsshipdb' and set the user id and password in the file src/META-INF/persistence.xml as needed to access it. Then run the JUnit4 test in test/de/vogella/jpa/hibernate/main/JpaTest.java.
  • Minor modifications were needed to the persistence.xml file to work under Hibernate 3.6.7. I didn't include those here because once they were made, the behavior was the same under both versions. (At least as far as hanging – I didn't investigate the Hibernate logs or the mysql engine status to see if they were different).
  • Although I started out using Java 1.7 and saw the hang with that version, for testing I ran Eclipse under 1.6 and set it to use a compiler target level of 1.6 to ensure as little changed as possible when changing JVMs.
  • Before trying MySQL 5.5, I changed some of the MySQL 5.6 settings:
    thread_handling (to one-per-connection)
    some of the logging settings
    but they made no difference (other than helping me narrow the scope of my work). (The MySQL 5.5 installation was used as-is.)
  • Also before trying MySQL 5.5, I used the MySQL installer to update 5.6. It said it updated it to 5.6.11, but the server still reports 5.6.10.
  • I did not try running the JUnit tests from the command line, so I can't be certain no recompilation was done when I changed the JVM. (I'm still becoming familiar with many of these tools and I don't know how to do that quite yet!)

Please advise if any additional information is needed.

Environment: Hibernate 4.1.11 Final
Hibernate 3.6.7 Final
jdk-6u45-windows-x64
jdk-7u17-windows-x64
jdk-7u21-windows-x64
MySQL: 5.5.30 (InnoDB, Community Server)
MySQL: 5.6.10-log (InnoDB, Community Server)
mysql-connector-java-5.1.24
JUnit4
Eclipse Juno (SR2), Java edition
Eclipse Juno (SR2), JEE edition
Microsoft Windows 7 Ultimate 64-bit (Intel Core i5-3360M, 8 GB RAM)
Project: Hibernate ORM
Labels: jpa2 hibernate core transaction
Priority: Major Major
Reporter: Ed Segall
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira