Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311078

Summary: Deadlock exists during merge of related object
Product: z_Archived Reporter: Gordon Yorke <gordon.yorke>
Component: EclipselinkAssignee: Gordon Yorke <gordon.yorke>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: eclipselink.foundation-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch none

Description Gordon Yorke CLA 2010-04-29 13:57:34 EDT
The MergeManager checks to see if it should invalidate an Entity even when the MergeManager does not actually merge anything into the object.  Second,  shouldInvalidate assumes that it has the lock for the CacheKey when the object being merged may not have changes but may only be referenced and in this case the MergeManager will not have the locks for this object and will be stuck waiting on the lock.

The scenario is as Follows:  
 A has OneToOne to B
   thread-1 acquires a deferred lock on B1
   thread-2 A1 is set to reference B1
   thread-2 commits
   thread-2 merge locks A1
   thread-2 attempts to get lock on B1 but cannot so transitions to    
            deferred and gets a deferred lock on B1
   thread-1 acquires deferred lock on A1
   thread-2 merges B1 without checking for changes
   thread-2 attempts shouldInvalidate and acquire lock on B1 but
              must wait
   thread-1 unable to release deferred locks while thread-2 waits.
Comment 1 Gordon Yorke CLA 2010-04-30 12:53:43 EDT
Created attachment 166644 [details]
Patch

This patch contains a couple fixes.  One is to insure we only check for invalidation if the ChangeSet has changes and therfore is already locked.  As well MergeManager.updateCacheKeyProperties has also been updated to ensure it only operates if it is able to obtain a lock.  This lock is also non-blocking.
Comment 2 Gordon Yorke CLA 2010-04-30 15:44:33 EDT
Checked in http://fisheye2.atlassian.com/changelog/eclipselink/trunk?cs=7120
reviewed by Andrei Ilitchev
Comment 3 Gordon Yorke CLA 2010-04-30 15:45:06 EDT
Not checked in code does not include the changes to the UOW in the patch.  These changes were included in the patch by mistake.
Comment 4 Gordon Yorke CLA 2010-05-03 09:00:41 EDT
The above comment should say "Note, checked in  code ..."
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:04:41 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink