Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » deadlock on select
deadlock on select [message #652015] Wed, 02 February 2011 12:46 Go to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
i have a select like this:
Query q = em.createQuery("select p from Pais p");


but sometimes, it hangs on q.getResultList(); so i close my app (an rcp app) an open it again. so i open the view that does this select, and then eclipselink says
 A signal was attempted before wait() on ConcurrencyManager. This normally means that an attempt was made to 
commit or rollback a transaction before it was started, or to rollback a transaction twice.

is it a dedalock?
heres my configs:

EntityManagerFactory: http://pastie.org/1521317
PaisDAO: http://pastie.org/1521318
the GermantechDAO superclass: http://pastie.org/1521319

any ideas?
thx!
Re: deadlock on select [message #652320 is a reply to message #652015] Thu, 03 February 2011 15:16 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

The only way to tell what is going on is to get a java thread dump and check out what other threads the process might be waiting on. What does your AggressiveCacheQueryRedirector do?

Regards,
Chris
Re: deadlock on select [message #652379 is a reply to message #652320] Thu, 03 February 2011 17:23 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
how do i do that?
Re: deadlock on select [message #652510 is a reply to message #652320] Fri, 04 February 2011 10:34 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
my aggressivecachequeryredirector

package br.com.germantech.cache;

import net.sf.ehcache.Cache;
import net.sf.ehcache.Element;

import org.eclipse.persistence.internal.sessions.AbstractRecord;
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.queries.DatabaseQuery;
import org.eclipse.persistence.queries.QueryRedirector;
import org.eclipse.persistence.sessions.Record;
import org.eclipse.persistence.sessions.Session;

public class AggressiveCacheQueryRedirector implements QueryRedirector {

	private static final long serialVersionUID = -7875812708013000151L;

	public Object invokeQuery(DatabaseQuery query, Record arguments, Session session) {

        // Para evitar loop infinito
        query.setDoNotRedirect(true);

        // Cacheando todas as caches do tipo 'read-all'
//        if (query.isReadAllQuery()) {

            // Procura ou cria o cache de acordo com a classe
            EhCacheWrapper cacheWrapper = EhCacheWrapper.getInstance();
            Cache cache = cacheWrapper.findOrCreateCache(query.getDescriptor().getJavaClass());

            // Cria uma key para o cache e armazena
            CacheKey key = new CacheKey(query.getName(), arguments.values().toArray());
            Element element;

            // Retorna o resultado cacheado
            if ((element = cache.get(key)) != null) {
                return element.getValue();

            // Executa a query e armazena os resultados em cache
            } else {
                Object object = query.execute((AbstractSession)session, (AbstractRecord) arguments);
                if (object != null) {
                    cache.put(new Element(key, object));
                }
                return object;
            }
         // Executa a query sem passar pelo cache
//        } else {
//            return query.execute((AbstractSession)session, (AbstractRecord) arguments);
//        }
    }


}
Re: deadlock on select [message #652543 is a reply to message #652015] Fri, 04 February 2011 13:40 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Java stack trace:
http://java.sun.com/developer/technicalArticles/Programming/ Stacktrace/
There are plenty of hits describing how to obtain one if you search for java thread dump or stack trace.

Best Regards,
Chris
Re: deadlock on select [message #653127 is a reply to message #652015] Tue, 08 February 2011 15:27 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Your query redirector seems to be attempt to do some kind of query cache. Note that EclipseLink support query caching, you can define any NamedQuery to cache its results using the query hint "eclipselink.query-results-cache".




James : Wiki : Book : Blog : Twitter
Re: deadlock on select [message #653165 is a reply to message #653127] Tue, 08 February 2011 17:54 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
i'm not using a NamedQuery, i'm using a 'read-all' query like this:

Query q = em.createQuery("select m from Municipio m where m.estados_id = :est");
q.setParameter("est", estado);
		
redirectQueryToCache(q)


i followed this tutorial: http://weblogs.java.net/blog/zarar/archive/2010/05/31/integr ating-eclipsellink-ehcache-cache-readall-and-native-queries and worked like a charm!

i putted all the 'Pais' entities on cache before the app start, and SOMETIMES it hangs. generally it doesn't hangs, but i can't trust on 'sometimes'

[Updated on: Tue, 08 February 2011 17:56]

Report message to a moderator

Re: deadlock on select [message #653185 is a reply to message #653165] Tue, 08 February 2011 18:39 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
Are you sure the record was not updated in any way, or is there maybe another record in the same table was updated (and the database has page level locking) and that its transaction is still open?
Re: deadlock on select [message #653187 is a reply to message #653185] Tue, 08 February 2011 18:53 Go to previous message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
i'm sure about the update...it's just a 'read' method...
now, about the transaction or page locking, i don't know... because the only method who manage a transaction is the 'saveOrUpdate' method

my base dao: http://pastie.org/1541926
Previous Topic:PostgreSQL/PostGIS stored function + Eclipselink converter problem
Next Topic:NullPointerException in eclipselink 2.1.2 code : JoinedAttributeManager.java
Goto Forum:
  


Current Time: Fri Mar 29 10:19:15 GMT 2024

Powered by FUDForum. Page generated in 0.03165 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top