Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327472 - MaxDB: test PessimisticLockingExtendedScopeTestSuite.testPESSMISTIC_ES5 fails with DEADLOCK
Summary: MaxDB: test PessimisticLockingExtendedScopeTestSuite.testPESSMISTIC_ES5 fai...
Status: RESOLVED 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: maxdb
Keywords:
Depends on:
Blocks: 284657 325839
  Show dependency tree
 
Reported: 2010-10-11 12:32 EDT by Adrian Goerler CLA
Modified: 2022-06-09 10:24 EDT (History)
4 users (show)

See Also:


Attachments
Java file allowing to reproduce the issue without EclipseLink (5.24 KB, text/x-java)
2010-10-12 09:34 EDT, Adrian Goerler CLA
no flags Details
on MaxDB, use native query to assert repeatable read of join table without accessing EntyD's table (3.58 KB, patch)
2010-10-22 03:14 EDT, Adrian Goerler CLA
no flags Details | Diff
on MaxDB, use native query to assert repeatable read of join table without accessing EntyD's table (4.65 KB, patch)
2010-11-22 03:23 EST, Adrian Goerler CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Goerler CLA 2010-10-11 12:32:35 EDT
If FK constraints are present, the test locking thread fails with "SQLTransactionRollbackException: [600]: Work rolled back,DEADLOCK DETECTED". 

The test suceeds if there are no FK constraints present. 

This seems to be a issue of MaxDB which should be followed up in MaxDB's bug trackig system.
Comment 1 Adrian Goerler CLA 2010-10-12 09:32:49 EDT
This issue is likely a MaxDB bug. And needs to be investigated. It is followed up in SAP's bug tracking system as internal issue "3138792 2010".

The outcome of the investigation is open.
Comment 2 Adrian Goerler CLA 2010-10-12 09:34:21 EDT
Created attachment 180666 [details]
Java file allowing to reproduce the issue without EclipseLink
Comment 3 Adrian Goerler CLA 2010-10-15 03:52:28 EDT
Analysis of the repro (https://bugs.eclipse.org/bugs/attachment.cgi?id=180666) provided by Holger Becker, MaxDB:

"Hi Adrian,

In MaxDB the foreign key records are locked before the primary key
record. This means in your case the delete on MY_BUG_A_D first
tries to lock MY_BUG_D and MY_BUG_A.
The first lock could be granted but the second one not because
of the prior select with exclusive lock.
So the delete have to wait but already hold one exclusive lock
on MY_BUG_D.
When the other task now tries to read this row the deadlock is
detected and you got error 600.
We could check if this behaviour could be changed so that the delete
first locks the primary record (in your case MY_BUG_A_D) this might
make the situation clearer and in your case it would avoid the deadlock
But I think it won't avoid any deadlock if you work with foreign keys.
Perhaps you could change the application logic with this knowledge
because I could not tell you when we will change the MaxDB behaviour.

Kind regards
Holger"
Comment 4 Adrian Goerler CLA 2010-10-22 03:09:28 EDT
One option to get rid of the deadlock on MaxDB would be to lock EntyA up-front before removing EntyD from the collection. However, testPESSMISTIC_ES5 wants to test that the join table is locked as well by the EXTENDED LOCK scope. Hence, upfront-locking EntyA would change the test.

Alternatively, a native query could be executed that queries the join table without accessing EntyD's table.
Comment 5 Adrian Goerler CLA 2010-10-22 03:14:48 EDT
Created attachment 181467 [details]
on MaxDB, use native query to assert repeatable read of join table without accessing EntyD's table
Comment 6 Adrian Goerler CLA 2010-11-22 03:23:30 EST
Created attachment 183552 [details]
on MaxDB, use native query to assert repeatable read of join table without accessing EntyD's table
Comment 7 Adrian Goerler CLA 2010-11-22 03:26:54 EST
Fixed test by using a native query on MaxDB
Reviewed by Tom
Tested on MaxDB

Checked in at #8530
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:17:15 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:24:52 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink