-->
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.  [ 3 posts ] 
Author Message
 Post subject: Deadlock detected
PostPosted: Thu Jun 17, 2010 6:37 am 
Newbie

Joined: Thu Jun 17, 2010 5:38 am
Posts: 2
We are experiencing a deadlock occasionally during a merge on an entity.

The entity - Application - has a OneToMany relationship with EduWish using CascadeType.ALL and CascadeType.DELETE_ORPHAN.
The EduWish below has three OneToOne relationships to EduWishInst.

Please see the entities in the code at the end of this message.

We are basically in a JPA setting but use CascadeType.DELETE_ORPHAN to make sure garbage data is not left in the database.

Calling jpaTemplate.merge(application) with an application that has some of its EduWish deleted can cause (moderate load suspected) a deadlock on the EduWishInst table:

The deadlock is on: delete from EduWishInst where id=:v0 from both sessions participating in the deadlock.

Code:
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TM-00016380-00000000        80      12    SX   SSX       84     926    SX   SSX
TM-00016380-00000000        84     926    SX   SSX       80      12    SX   SSX


It seems each session tries to get a table lock while already holding a row lock.

Any idea why this is happening? We suspect that the DELETE_ORPHAN may be the culprit.

The environment is:

Weblogic 9.2
Oracle 11g
JPA
Hibernate 3.2.6.ga
Hibernate-entitymanager 3.3.2.GA
Spring 2.5.6

Code:
@Entity
public class Application {
...
   @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
   @Fetch(value = FetchMode.SUBSELECT)
   @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
   private List<EduWish> educationWishes;
...
}

@Entity
public class EduWish {
...
   @OneToOne(cascade = {CascadeType.ALL},fetch = FetchType.EAGER)
   private EduWishInst alfaInstitution;
   @OneToOne(cascade = {CascadeType.ALL},fetch = FetchType.EAGER)
   private EduWishInst bravoInstitution;
   @OneToOne(cascade = {CascadeType.ALL},fetch = FetchType.EAGER)
   private EduWishInst charlieInstitution;
...
}

@Entity
public class EduWishInst {
...
}


Top
 Profile  
 
 Post subject: Re: Deadlock detected
PostPosted: Fri Jun 18, 2010 4:56 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
using the Spring templates Hibernate will loose control about the proper ordering of actions it would take. Could you please try without the templates and use the Entitymanager

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Deadlock detected
PostPosted: Fri Jun 18, 2010 5:07 am 
Newbie

Joined: Thu Jun 17, 2010 5:38 am
Posts: 2
But can that explain why it tries to get a SSX lock when it is just deleting a single row?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.