Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325839 - MaxDB does not support FOR UPDATE locking with queries that involve multiple tables
Summary: MaxDB does not support FOR UPDATE locking with queries that involve multiple ...
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: 326799 327472
Blocks: 284657
  Show dependency tree
 
Reported: 2010-09-21 08:09 EDT by Adrian Goerler CLA
Modified: 2022-06-09 10:35 EDT (History)
4 users (show)

See Also:


Attachments
use "WITH LOCK [(NOWAIT)] EXCLUSIVE" for pessimistic locking on maxdb (1.27 KB, patch)
2010-09-24 03:39 EDT, Adrian Goerler CLA
no flags Details | Diff
patch to avoid deadlock in testLockWithJoinedInheritanceStrategy (4.99 KB, patch)
2010-09-24 04:08 EDT, Adrian Goerler CLA
no flags Details | Diff
patch submnitted to avoid deadlock in testLockWithJoinedInheritanceStrategy (5.12 KB, patch)
2010-09-27 05:39 EDT, 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-09-21 08:09:11 EDT
Several test fail on SAP MaxDB that atempt to lock multiple tables:

eclipselink.core.test:
- PessimisticLockTest(mode=1)
- PessimisticLockEmptyTransactionTest

eclipselink.jpa.test:
- testPESSIMISTIC_READLockWithNoChanges
- testPESSIMISTIC_WRITELockWithNoChanges
- testPESSIMISTIC_ExtendedScope
- testPessimisticLockHintStartsTransaction
- testLockWithJoinedInheritanceStrategy
- testPESSIMISTIC_FORCE_INCREMENTLock
- testGetLockModeType
Comment 1 Adrian Goerler CLA 2010-09-24 02:41:43 EDT
On MaxDB, the desired behaviour can be achieved by appending 

"WITH LOCK [(NOWAIT)] EXCLUSIVE" to the select statement.
Comment 2 Adrian Goerler CLA 2010-09-24 03:07:31 EDT
Using "WITH LOCK [(NOWAIT)] EXCLUSIV", the test testLockWithJoinedInheritanceStrategy deadlocks on MaxDB:

The test atemps to pessimistically lock a "LargeProject" entity, which has inheritance strategy JOINED. The entity is firstly locked. With a second entity manager, it is atempted to obtain a lock with NOWAIT, which should fail with a PessimisticLockException. 

However, as the entity has joined inheritances, firstly the query (in the following referred to as "Q1")

SELECT DISTINCT t0.PROJ_TYPE FROM CMP3_PROJECT t0, CMP3_LPROJECT t1 WHERE (((t0.PROJ_ID = ?) AND (t1.PROJ_ID = t0.PROJ_ID)) AND (t0.PROJ_TYPE IN (L, H)))

(assumingly to determine the concrete class in the hierarchy). This query does not use NOWAIT. As the test is executed with isolation level READ_COMMITED, this query will block causing a deadlock.

On Oracle, we are having consistent read and hence Q1 won't block. 

On MySQL, the test succeeds accidently: FOR UPDATE NOWAIT causes a syntax error which is somehow wrapped into an (expected) PessimiticLockException. This remains to be analyzed.
Comment 3 Adrian Goerler CLA 2010-09-24 03:39:51 EDT
Created attachment 179499 [details]
use "WITH LOCK [(NOWAIT)] EXCLUSIVE" for pessimistic locking on maxdb

Checked in at rev 8237.
Comment 4 Adrian Goerler CLA 2010-09-24 04:08:22 EDT
Created attachment 179500 [details]
patch to avoid deadlock in testLockWithJoinedInheritanceStrategy
Comment 5 Adrian Goerler CLA 2010-09-24 04:13:35 EDT
The patch https://bugs.eclipse.org/bugs/attachment.cgi?id=179500 does not fix testLockWithJoinedInheritanceStrategy but just avoids the deadlock and causes a failure instead. The issue remains to be discussed.

Tested on 
Oracle -> OK
MaxDB -> Failure, but no deadlock 
MySQL -> false OK (hides syntax error (see above))
Comment 6 Adrian Goerler CLA 2010-09-27 05:39:02 EDT
Created attachment 179612 [details]
patch submnitted to avoid deadlock in testLockWithJoinedInheritanceStrategy

Reviewed by Michael O' Brien
Tested on MaxDB -> testLockWithJoinedInheritanceStrategy now fails but does not deadlock any longer
Comment 7 Adrian Goerler CLA 2010-09-27 05:42:36 EDT
Comment on attachment 179612 [details]
patch submnitted to avoid deadlock in testLockWithJoinedInheritanceStrategy

Checked in at #8244.
Comment 8 Adrian Goerler CLA 2010-09-27 07:29:16 EDT
Issue is now solved for 

eclipselink.core.test:
- PessimisticLockTest(mode=1)
- PessimisticLockEmptyTransactionTest

eclipselink.jpa.test:
- testPESSIMISTIC_READLockWithNoChanges
- testPESSIMISTIC_WRITELockWithNoChanges
- testPESSIMISTIC_ExtendedScope
- testPessimisticLockHintStartsTransaction
- testPESSIMISTIC_FORCE_INCREMENTLock
- testGetLockModeType


remains to be analyzed for 

eclipselink.jpa.test:
- testLockWithJoinedInheritanceStrategy
Comment 9 Henrik Lindberg CLA 2010-10-01 17:06:23 EDT
This issue is marked to be blocked by bug 326779 - I think that was a mistake as that issue has to do with a proposal provider for the b3 DSL editor.
Comment 10 Adrian Goerler CLA 2010-11-22 03:27:31 EST
All pessimistic locking tests are now passing.
Comment 11 Eclipse Webmaster CLA 2022-06-09 10:14:42 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 12 Eclipse Webmaster CLA 2022-06-09 10:35:04 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink