-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Infinite Loop Possible Through Non-synchronisd use LRUMap
PostPosted: Tue Feb 14, 2006 12:02 pm 
Newbie

Joined: Wed Sep 15, 2004 8:29 am
Posts: 2
Under very high concurrency I am getting all threads using hibernate stuck on:

Name: http-8080-Processor22
State: RUNNABLE
Total blocked: 183,622 Total waited: 49,453

Stack trace:
java.util.HashMap.containsKey(Unknown Source)
org.apache.commons.collections.SequencedHashMap.containsKey(Unknown Source)
org.apache.commons.collections.LRUMap.put(Unknown Source)
org.hibernate.util.SoftLimitMRUCache.put(SoftLimitMRUCache.java:60)
org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:121)
org.hibernate.impl.AbstractSessionImpl.getNativeSQLQueryPlan(AbstractSessionImpl.java:140)
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:147)
org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)

there is a race condition possible within Hashmap, that is well described in
http://blogs.opensymphony.com/plightbo/ ... nfini.html

in this case we are getting stuck in loop in:
(from java.util.Hashmap for jdk1.5.0_04)

public boolean containsKey(Object key) {
Object k = maskNull(key);
int hash = hash(k);
int i = indexFor(hash, table.length);
Entry e = table[i];
while (e != null) {
if (e.hash == hash && eq(k, e.key))
return true;
e = e.next;
}
return false;
}


SoftLimitMRUCache does not seem to have enough synchronisation.

javadoc for LRUMap suggests:

* A synchronized version can be obtained with:
* <code>Collections.synchronizedMap( theMapToSynchronize )</code>
* If it will be accessed by multiple threads, you _must_ synchronize access
* to this Map. Even concurrent get(Object) operations produce indeterminate
* behaviour.

I have tested under very high concurent load with the following changes:

- removed methods: entries() and softEntries() - they are not used and give access in dangerous way to the Map's iterators.

- synchronized methods: softSize(), size(), put() - get() was already synchronised.

testing load = 10 concurrent users, 100,000 requests each over 90 mins
- it'll take a bunch of testing to be sure I get no more of these
- previously I would run c.500,000 requests before it would hit, but the problem would then escalate fast as the busy loop takes all processor cycles.)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 1:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
These kinds of things are much better as a bug report...
http://opensource.atlassian.com/project ... e/HHH-1486


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.