Quantcast

Deadlock in Grails 2.0 RC1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Deadlock in Grails 2.0 RC1

fatzopilot
Hi,

there is a deadlock situation in my project under high load in Grails 2.0 RC1 which wasn't there in Grails 1.3.7. Seems to be some kind of caching issue.
Fortunately, I was able to reproduce this behavior (which I believe is not by poor design) in a vanilla Grails project and with little code (you can find it below). It is a bit more complex than really necessary, though.
Just run it, and it will get stuck after a few iterations. Attached is the vanilla project and a profiler output which seems to indicate a problem with a java.util.Map and concurrency.
The use of Gpars should not be the problem since it is just used to mimic JBoss Netty behaviour (Worker threads).
Since I am unable to tell were the problem really is (myself, Spring, Hibernate, Grails, ect.) I'd like to ask if someone with more in depth knowledge could forward this to the appropriate bugtracker.

Thanks
fatzopilot

lockingIssue.zip
profilerOutput.mht

import groovyx.gpars.GParsPool
import lockingIssue.domainClass.Aa
import lockingIssue.java.SomeJavaClass

class BootStrap {

    def init = { servletContext ->
		System.out.println("Starting... ");
		GParsPool.withPool {
			System.out.println("In the pool... ");
			(1..1000).eachParallel{outerIt ->
				SomeJavaClass someJavaClass = new SomeJavaClass();
				Aa aa = someJavaClass.getSomething(outerIt);
				System.out.println("This is "+outerIt);
				(1..1000).each{
					someJavaClass.attachSomething(aa);
				}
			}
		}
    }
    def destroy = {
    }
}
===
package lockingIssue.service

import lockingIssue.domainClass.Aa;
import lockingIssue.domainClass.Bb;

class SomeService {

    def Aa getAA(long id) {
		Aa aa = Aa.findOrSaveById(id);
		return aa;
    }
	
	def Bb attachNewBtoA(Aa aa){
		aa.refresh();
		Bb bb = new Bb(anA:aa);
		bb.save();
		aa.lastBb == bb;
		aa.save();
		return bb;
	}
}
==
package lockingIssue.domainClass

class Aa {
	
	String p1;
	String p2;
	Bb lastBb; 

	static constraints = {
		p1(nullable:true)
		p2(nullable:true)
		lastBb(nullable:true)
	}
	
	static mapping = {
		lastBb fetch:"join"
		id generator:'assigned'
	}
}
==
package lockingIssue.domainClass

class Bb {
	
	Aa anA;

    static constraints = {
    }
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deadlock in Grails 2.0 RC1

Graeme Rocher-4
Administrator
There was a deadlock issue fixed, it may be related, regardless please
raise a JIRA and attach the example

Thanks

On Tue, Nov 22, 2011 at 4:49 PM, fatzopilot <[hidden email]> wrote:

> Hi,
>
> there is a deadlock situation in my project under high load in Grails 2.0
> RC1 which wasn't there in Grails 1.3.7. Seems to be some kind of caching
> issue.
> Fortunately, I was able to reproduce this behavior (which I believe is not
> by poor design) in a vanilla Grails project and with little code (you can
> find it below). It is a bit more complex than really necessary, though.
> Just run it, and it will get stuck after a few iterations. Attached is the
> vanilla project and a profiler output which seems to indicate a problem with
> a java.util.Map and concurrency.
> The use of Gpars should not be the problem since it is just used to mimic
> JBoss Netty behaviour (Worker threads).
> Since I am unable to tell were the problem really is (myself, Spring,
> Hibernate, Grails, ect.) I'd like to ask if someone with more in depth
> knowledge could forward this to the appropriate bugtracker.
>
> Thanks
> fatzopilot
>
> http://grails.1312388.n4.nabble.com/file/n4096192/lockingIssue.zip
> lockingIssue.zip
> http://grails.1312388.n4.nabble.com/file/n4096192/profilerOutput.mht
> profilerOutput.mht
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Deadlock-in-Grails-2-0-RC1-tp4096192p4096192.html
> Sent from the Grails - dev mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deadlock in Grails 2.0 RC1

fatzopilot
Loading...