<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <base href="https://hibernate.atlassian.net" />
<title>Message Title</title>
</head>
<body class="jira" style="color: #333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429">
<table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<!-- header here -->
<tr>
<td id="header-pattern-container" style="padding: 0px; border-collapse: collapse; padding: 10px 20px">
<table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="header-avatar-image-container" valign="top" style="padding: 0px; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px"> <img id="header-avatar-image" class="image_fix" src="https://secure.gravatar.com/avatar/fc24ff369f892ea9c155e48c5b2ee633?d=mm&s=48" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top" />
</td>
<td id="header-text-container" valign="middle" style="padding: 0px; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="Vyacheslav Nikulin" id="email_Vyacheslav Nikulin" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=Vyacheslav+Nikulin" style="color:#6c797f;; color: #3b73af; text-decoration: none">Vyacheslav Nikulin</a> <strong>edited a comment</strong> on <a href="https://hibernate.atlassian.net/browse/HHH-9070" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-static-bug-23a565f1-7391-42cf-acdc-a9e63b475166" height="16" width="16" border="0" align="absmiddle" alt="Bug" /> HHH-9070</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="email-content-container" style="padding: 0px; border-collapse: collapse; padding: 0 20px">
<table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-spacing: 0; border-collapse: separate">
<tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<td class="email-content-rounded-top mobile-expand" style="padding: 0px; border-collapse: collapse; color: #fff; padding: 0 15px 0 16px; height: 15px; background-color: #fff; border-left: 1px solid #ccc; border-top: 1px solid #ccc; border-right: 1px solid #ccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly">
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff">
<table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td style="vertical-align: top;; padding: 0px; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HHH-9070" style="color: #3b73af; text-decoration: none">Re: Deadlock using ehcache 2.7.5 and CacheConcurrencyStrategy.READ_WRITE </a> </span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="text-paragraph-pattern-top" class="email-content-main mobile-expand comment-top-special-margin comment-top-pattern" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff; border-bottom: none; padding-bottom: 0">
<table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px">
<tr>
<td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0px; border-collapse: collapse; padding: 0 0 10px 0; padding-top: 10px"> <span class="diffcontext">After several hours we were able to create a test case.<br />Here</span> <span class="diffaddedchars" style="background-color:#ddfade;"> is</span> <span class="diffcontext"> all data that you need. <br /><br />{code:title=ehcache.xml}<br /><ehcache updateCheck="false"<br /> monitoring="on"<br /> dynamicConfig="false"<br /> name="TestCache"> <br /> <defaultCache maxEntriesLocalHeap="2"/> <br /></ehcache><br />{code}<br /><br />{code:title=hibernate.xml}<br /><property name="hibernate.cache.use_second_level_cache">true</property><br /><property name="net.sf.ehcache.configurationResourceName">ehcache.xml</property><br /><property name="hibernate.default_batch_fetch_size">0</property><br /><property name="hibernate.cache.provider_class">org.hibernate.cache.ehcache.EhCacheProvider</property><br /><property name="hibernate.cache.use_structured_entries">true</property><br /><property name="hibernate.cache.use_query_cache">true</property><br /><property name="hibernate.cache.use_minimal_puts">true</property><br /><property name="hibernate.max_fetch_depth">1</property><br /><property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property><br />{code}<br /><br />{code:title=create.sql}<br />drop table if exists EhCacheDeadLockTest;<br />create table EhCacheDeadLockTest (`id` int not null,`value` varchar(255) not null, primary key (`id`) ) engine=InnoDB;<br />insert into EhCacheDeadLockTest values (1,'1');<br />insert into EhCacheDeadLockTest values (2,'2');<br />insert into EhCacheDeadLockTest values (10010003,'3');<br />insert into EhCacheDeadLockTest values (10010004,'4');<br />{code}<br /><br />{code:title=EhCacheDeadLockEntity.java|borderStyle=solid}<br />import org.hibernate.annotations.Cache;<br />import org.hibernate.annotations.CacheConcurrencyStrategy;<br /><br />import javax.persistence.Column;<br />import javax.persistence.Entity;<br />import javax.persistence.Id;<br />import javax.persistence.Table;<br /><br />@Entity<br />@Table( name = "EhCacheDeadLockTest" )<br />@Cache( usage = CacheConcurrencyStrategy.READ_WRITE )<br />public class EhCacheDeadLockEntity<br />{<br /> @Id<br /> @Column( name = "id" )<br /> private int id;<br /><br /> @Column( name = "value" )<br /> private String value;<br /><br /> public int getId()<br /> {<br /> return id;<br /> }<br /><br /> public void setId( int id )<br /> {<br /> this.id = id;<br /> }<br /><br /> public String getValue()<br /> {<br /> return value;<br /> }<br /><br /> public void setValue( String value )<br /> {<br /> this.value = value;<br /> }<br /><br /> @Override<br /> public String toString()<br /> {<br /> return "EhCacheDeadLockEntity{" +<br /> "id=" + id +<br /> ", value='" + value + '\'' +<br /> '}';<br /> }<br /><br /> @Override<br /> public boolean equals( Object o )<br /> {<br /> if ( this == o ) return true;<br /> if ( !( o instanceof EhCacheDeadLockEntity ) ) return false;<br /><br /> EhCacheDeadLockEntity that = (EhCacheDeadLockEntity) o;<br /><br /> if ( id != that.id ) return false;<br /><br /> return true;<br /> }<br /><br /> @Override<br /> public int hashCode()<br /> {<br /> return id;<br /> }<br />}<br /><br />{code}<br /><br />{code:title=EhCacheDeadLockTest.java|borderStyle=solid}<br /><br />private static final int[] ID_LIST = new int[]{ 1, 2, 10010003, 10010004 };<br />static volatile boolean finish = false;<br />static AtomicInteger counter = new AtomicInteger();<br /><br />class Worker implements Runnable<br /> {<br /> Random rnd = new Random();<br /><br /> @Override<br /> public void run()<br /> {<br /> while ( !finish )<br /> {<br /> try<br /> {<br /> final Session session = HibernateFactory.getCurrentSession();<br /> Transaction tx = session.beginTransaction();<br /> try<br /> {<br /> session.clear();<br /> int id = ID_LIST[rnd.nextInt( ID_LIST.length )];<br /> EhCacheDeadLockEntity entity = (EhCacheDeadLockEntity) session.get( EhCacheDeadLockEntity.class, id );<br /> entity.setValue( String.valueOf( rnd.nextInt() ) );<br /> session.save( entity );<br /> }<br /> finally<br /> {<br /> tx.commit();<br /> counter.incrementAndGet();<br /> }<br /> }<br /> catch ( Throwable e )<br /> {<br /> System.out.println( e );<br /> }<br /> }<br /> }<br /> }<br /><br /> @Test<br /> public void testDeadLock() throws Exception<br /> {<br /> final int THREAD_COUNT = 32;<br /> Worker[] workers = new Worker[THREAD_COUNT];<br /> Thread[] threads = new Thread[THREAD_COUNT];<br /><br /> for ( int i = 0; i < workers.length; i++ ) workers[i] = new Worker();<br /><br /> for ( int i = 0; i < workers.length; i++ ) threads[i] = new Thread( workers[i] );<br /><br /> for ( int i = 0; i < workers.length; i++ ) threads[i].start();<br /><br /> Thread.sleep( 5000 );<br /> System.out.println( "counter=" + counter.get() );<br /> finish = true;<br /><br /> for ( int i = 0; i < workers.length; i++ ) threads[i].join();<br />}<br />{code}<br /></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff">
<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px">
<tr>
<td id="actions-pattern-container" valign="middle" style="padding: 0px; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0">
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td class="actions-pattern-action-icon-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0px; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HHH-9070#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-a5834320-dca5-4a51-951b-e87a292cbc67" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle" /> </a>
</td>
<td class="actions-pattern-action-text-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://hibernate.atlassian.net/browse/HHH-9070#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<tr>
<td class="email-content-rounded-bottom mobile-expand" style="padding: 0px; border-collapse: collapse; color: #fff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #fff; border-top: 0; border-left: 1px solid #ccc; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="footer-pattern" style="padding: 0px; border-collapse: collapse; padding: 12px 20px">
<table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0px; border-collapse: collapse; color: #999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px">
This message was sent by Atlassian JIRA <span id="footer-build-information">(v6.2-OD-10-004-WN#6253-<span title="0f638781a9eb90c00e546dda3da3aa1c24cb2738" data-commit-id="0f638781a9eb90c00e546dda3da3aa1c24cb2738}">sha1:0f63878</span>)</span>
</td>
<td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0px; border-collapse: collapse; padding-left: 20px; vertical-align: top">
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="footer-pattern-logo-desktop-padding" style="padding: 0px; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="cid:jira-generated-image-static-footer-desktop-logo-724e5c7e-1216-4320-87b5-c010ce8e4bcb" alt="Atlassian logo" title="Atlassian logo" width="169" height="36" class="image_fix" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>