Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324459 - Potential deadlock when using fetch joins
Summary: Potential deadlock when using fetch joins
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-03 13:38 EDT by Tom Ware CLA
Modified: 2022-06-09 10:31 EDT (History)
2 users (show)

See Also:


Attachments
Potential fix (78.32 KB, patch)
2010-09-03 13:41 EDT, Tom Ware CLA
no flags Details | Diff
Suggested fix with test case (97.20 KB, patch)
2010-09-17 16:00 EDT, Tom Ware CLA
no flags Details | Diff
Updated patch (28.59 KB, patch)
2010-09-22 10:21 EDT, Tom Ware CLA
no flags Details | Diff
Updated patch (32.62 KB, patch)
2010-09-22 15:01 EDT, Tom Ware CLA
no flags Details | Diff
Updated patch on 2.1.2 stream (34.32 KB, patch)
2010-10-29 10:15 EDT, Peter Krogh CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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