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

Bug 324459

Summary: Potential deadlock when using fetch joins
Product: z_Archived Reporter: Tom Ware <tom.ware>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: christopher.delahunt, michael.f.obrien
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Potential fix
none
Suggested fix with test case
none
Updated patch
none
Updated patch
none
Updated patch on 2.1.2 stream none

Description Tom Ware CLA 2010-09-03 13:38:55 EDT
Deferred locking settings are not maintained when using fetch joins.

This bug should be reproducable in a way very similar to Bug 262157, except with a Fetch join in the place where Inheritance was causing the issue.

Attaching a potential patch.  A test case will follow
Comment 1 Tom Ware CLA 2010-09-03 13:41:00 EDT
Created attachment 178181 [details]
Potential fix
Comment 2 Tom Ware CLA 2010-09-03 13:41:35 EDT
Attached a potential fix which cascades the deferred locking settings to object builds for fetch joins.
Comment 3 Tom Ware CLA 2010-09-17 15:58:40 EDT
The deadlock occurs in the following situation

- Bidirectional relationship between A and B
- B has no EAGER ForeignReferenceMappings and, hence, will use Active Locking by default
- A->B is EAGER
- B->A is LAZY
- Query1 is ReadObjectQuery for A
- Query 2 is ReadObjectQuery for B with a fetch join to A
- Run Query 1 and stop it after it gets the lock for A, but before it gets the lock for B
- Run Query 2
- Allow Query 1 to continue

Query 1 will deadlock when it tries to get an active lock for A.
Comment 4 Tom Ware CLA 2010-09-17 16:00:19 EDT
Created attachment 179147 [details]
Suggested fix with test case
Comment 5 Tom Ware CLA 2010-09-17 16:01:15 EDT
The attached fix cascades deferred locking settings for any object that uses deferred locking to any additional EAGER or Joined attributes retrieved by the same query.
Comment 6 Tom Ware CLA 2010-09-22 10:21:07 EDT
Created attachment 179381 [details]
Updated patch
Comment 7 Tom Ware CLA 2010-09-22 15:01:49 EDT
Created attachment 179400 [details]
Updated patch
Comment 8 Tom Ware CLA 2010-09-23 13:55:26 EDT
Fixed in trunk.

Reviewed by James Sutherland and Gordon Yorke

Added test to simultaneous test model
Comment 9 Chris Delahunt CLA 2010-10-28 14:59:31 EDT
Fix also checked into 2.1.2
Completed: At revision: 8437
Comment 10 Peter Krogh CLA 2010-10-29 10:15:32 EDT
Created attachment 182037 [details]
Updated patch on 2.1.2 stream
Comment 11 Eclipse Webmaster CLA 2022-06-09 10:31:07 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink