<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) {
#email-body { min-width: 30em !important; }
#email-page { padding: 8px !important; }
#email-banner { padding: 8px 8px 0 8px !important; }
#email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; }
#email-fields { padding: 0 8px 8px 8px !important; }
#email-gutter { width: 0 !important; }
}
</style>
<div id="email-body">
<table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;">
<tr valign="top">
<td id="email-page" style="padding:16px !important;">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px solid #bbbbbb;color:#000000;width:100%;">
<tr valign="top">
<td bgcolor="#3e4c4e" style="background-color:#3e4c4e;color:#ffffff;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img src="https://www.jboss.org/dms/hibernate/images/jira/jiraheader_hibernate.png" alt="" style="vertical-align:top;" /></td>
</tr><tr valign="top">
<td id="email-banner" style="padding:32px 32px 0 32px;">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;">
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;">
<img id="email-avatar" src="https://secure.gravatar.com/avatar/3ee8f9d07708a3a78f3da198fd1edf5c?d=mm&s=48" alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px 0;" />
<div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;">
<a class="user-hover" rel="esegall" id="email_esegall" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=esegall" style="color:#6c797f;">Ed Segall</a>
created <img src="https://hibernate.atlassian.net/images/icons/issuetypes/bug.png" height="16" width="16" border="0" align="absmiddle" alt="Bug"> <a style='color:#6c797f;text-decoration:none;' href='https://hibernate.atlassian.net/browse/HHH-8202'>HHH-8202</a>
</div>
<div id="email-summary" style="font-size:16px;line-height:20px;padding:2px 0 16px 0;">
<a style='color:#6c797f;text-decoration:none;' href='https://hibernate.atlassian.net/browse/HHH-8202'><strong>Example works under Java 1.6 but under Java 1.7 JVM usually hangs while holding table metadata lock</strong></a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td id="email-fields" style="padding:0 32px 32px 32px;">
<table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%">
<tr valign="top">
<td id="email-gutter" style="width:64px;white-space:nowrap;"></td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Issue Type:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<img src="https://hibernate.atlassian.net/images/icons/issuetypes/bug.png" height="16" width="16" border="0" align="absmiddle" alt="Bug"> Bug
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Affects Versions:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
4.1.11, 3.6.7 </td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Assignee:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
Unassigned
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Attachments:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
console log with sql on.txt, hibernate-hang.jar, show engine innodb status.txt </td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Components:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
annotations, core </td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Created:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
23/Apr/13 3:47 PM
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Description:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<p style='margin-top:0;margin-bottom:10px;'>While learning JPA in the context of Hibernate, I adapted the following tutorial to work with Hibernate and MySQL:</p>
<p style='margin-top:0;margin-bottom:10px;'><a href="http://www.vogella.com/articles/JavaPersistenceAPI/article.html" class="external-link" rel="nofollow">http://www.vogella.com/articles/JavaPersistenceAPI/article.html</a></p>
<p style='margin-top:0;margin-bottom:10px;'>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. </p>
<p style='margin-top:0;margin-bottom:10px;'>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. </p>
<p style='margin-top:0;margin-bottom:10px;'>While it's hung, if I try to access the tables from the mysql command line, as in:</p>
<p style='margin-top:0;margin-bottom:10px;'> select * from relationsshipdb.person;</p>
<p style='margin-top:0;margin-bottom:10px;'>It hangs there too. </p>
<p style='margin-top:0;margin-bottom:10px;'>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:</p>
<p style='margin-top:0;margin-bottom:10px;'>INFO: HHH000227: Running hbm2ddl schema export<br/>
Hibernate: <br/>
alter table Person <br/>
drop <br/>
foreign key FK8E488775B78CE81F</p>
<p style='margin-top:0;margin-bottom:10px;'>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. </p>
<p style='margin-top:0;margin-bottom:10px;'>To assist in fault isolation I kept the modifications I made as simple as possible and tried varying many different factors including:</p>
<ul class="alternate" type="square">
        <li>MySQL version (5.5.30 vs 5.6.10)</li>
        <li>Hibernate version (3.6.7 Final vs 4.1.11 Final)</li>
        <li>Upgraded JRE (from 1.7.0_u17 to 1.7.0_u21)</li>
        <li>Eclipse (from JEE to plain Java version, in case the SE-oriented tutorial I used wasn't compatible with a JEE environment).</li>
</ul>
<p style='margin-top:0;margin-bottom:10px;'>but the only thing I've found that doesn't hang is using a 1.6 JVM version (specifically, 1.6.0_45). </p>
<p style='margin-top:0;margin-bottom:10px;'>Of note: </p>
<ul class="alternate" type="square">
        <li>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.</li>
</ul>
<ul class="alternate" type="square">
        <li>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).</li>
</ul>
<ul class="alternate" type="square">
        <li>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.</li>
</ul>
<ul class="alternate" type="square">
        <li>Before trying MySQL 5.5, I changed some of the MySQL 5.6 settings:<br/>
thread_handling (to one-per-connection)<br/>
some of the logging settings<br/>
but they made no difference (other than helping me narrow the scope of my work). (The MySQL 5.5 installation was used as-is.)</li>
</ul>
<ul class="alternate" type="square">
        <li>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.</li>
</ul>
<ul class="alternate" type="square">
        <li>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!)</li>
</ul>
<p style='margin-top:0;margin-bottom:10px;'>Please advise if any additional information is needed. </p>
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Environment:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
Hibernate 4.1.11 Final
<br/>
Hibernate 3.6.7 Final
<br/>
jdk-6u45-windows-x64
<br/>
jdk-7u17-windows-x64
<br/>
jdk-7u21-windows-x64
<br/>
MySQL: 5.5.30 (InnoDB, Community Server)
<br/>
MySQL: 5.6.10-log (InnoDB, Community Server)
<br/>
mysql-connector-java-5.1.24
<br/>
JUnit4
<br/>
Eclipse Juno (SR2), Java edition
<br/>
Eclipse Juno (SR2), JEE edition
<br/>
Microsoft Windows 7 Ultimate 64-bit (Intel Core i5-3360M, 8 GB RAM)
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Project:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a style="color:#6c797f;" href="https://hibernate.atlassian.net/browse/HHH">Hibernate ORM</a>
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Labels:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
jpa2
hibernate
core
transaction
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Priority:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<img src="https://hibernate.atlassian.net/images/icons/priorities/major.png" height="16" width="16" border="0" align="absmiddle" alt="Major"> Major
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Reporter:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a class="user-hover" rel="esegall" id="email_esegall" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=esegall" style="color:#6c797f;">Ed Segall</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td><!-- End #email-page -->
</tr>
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-align:center;">
This message is automatically generated by JIRA.<br />
If you think it was sent incorrectly, please contact your JIRA administrators<br />
For more information on JIRA, see: <a style='color:#6c797f;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a>
</td>
</tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->