Skip to content

Commit 6405214

Browse files
author
Radek Felcman
authored
Cache DeadLock Detection test move from org.eclipse.persistence.jpa.jse.test into new org.eclipse.persistence.jpa.testapps.deadlock.diagnostic Maven module (#2304) (#2447)
Cache DeadLock Detection test move from org.eclipse.persistence.jpa.jse.test into new org.eclipse.persistence.jpa.testapps.deadlock.diagnostic Maven module There is move into new Maven module some test refactor and new test for WriteLockManager.acquireLocksForClone(...) method call and logging. ConcurrentReadFetchJoinWithUOWLocksTest fix to allow test threads to finish. Signed-off-by: Radek Felcman <radek.felcman@oracle.com> (cherry picked from commit 3b66e99)
1 parent 7ae59e9 commit 6405214

19 files changed

Lines changed: 702 additions & 272 deletions

File tree

foundation/eclipselink.core.test/src/it/java/org/eclipse/persistence/testing/tests/simultaneous/ConcurrentReadFetchJoinWithUOWLocksTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2025 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -72,7 +72,7 @@ public void test(){
7272
clonedPerson.setHobby(clonedProject);
7373
uow.writeChanges();
7474

75-
Thread thread1 = new Thread(new ProjectReader(server.acquireClientSession(), project.getId()));
75+
Thread thread1 = new Thread(new ProjectReader(server.acquireClientSession(), project.getId()), "Test Thread 1");
7676
ConcurrentProject.RUNNING_TEST = ConcurrentProject.READ_WITH_UOW_LOCKS_TESTS;
7777
//start reading Project, and have the thread wait while building DTF mappings
7878
thread1.start();
@@ -84,7 +84,7 @@ public void test(){
8484

8585
//start uow commit, which will get locks on Person+Address, commit, then merge.
8686
//merge should get a deferred lock on Project.
87-
Thread thread2 = new Thread(new UOWCommit(uow));
87+
Thread thread2 = new Thread(new UOWCommit(uow), "Test Thread 2");
8888
thread2.start();
8989

9090
//while waiting, thread1 should wake and try to get a lock on Address. It will deadlock if it
@@ -112,7 +112,9 @@ public void verify(){
112112
}
113113

114114
@Override
115-
public void reset(){
115+
public void reset() throws InterruptedException {
116+
//To give threads from the test() chance to finish
117+
Thread.sleep(1000);
116118
ConcurrentProject.RUNNING_TEST = ConcurrentProject.NONE;
117119
UnitOfWork uow = getSession().acquireUnitOfWork();
118120

foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/WriteLockManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public class WriteLockManager {
131131

132132
private final Lock instancePrevailingQueueLock = new ReentrantLock();
133133

134+
private static final String ACQUIRE_LOCK_FOR_CLONE_METHOD_NAME = WriteLockManager.class.getName() + ".acquireLocksForClone(...)";
135+
134136
public WriteLockManager() {
135137
this.prevailingQueue = new ExposedNodeLinkedList();
136138
}
@@ -166,9 +168,8 @@ public Map acquireLocksForClone(Object objectForClone, ClassDescriptor descripto
166168
// of the concurrency manager that we use for creating the massive log dump
167169
// to indicate that the current thread is now stuck trying to acquire some arbitrary
168170
// cache key for writing
169-
StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[1];
170171
lastCacheKeyWeNeededToWaitToAcquire = toWaitOn;
171-
lastCacheKeyWeNeededToWaitToAcquire.putThreadAsWaitingToAcquireLockForWriting(currentThread, stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + "(...)");
172+
lastCacheKeyWeNeededToWaitToAcquire.putThreadAsWaitingToAcquireLockForWriting(currentThread, ACQUIRE_LOCK_FOR_CLONE_METHOD_NAME);
172173

173174
// Since we know this one of those methods that can appear in the dead locks
174175
// we threads frozen here forever inside of the wait that used to have no timeout

jpa/eclipselink.jpa.test.jse/pom.xml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2019, 2024 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2019, 2025 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0 which is available at
@@ -41,16 +41,6 @@
4141
<artifactId>junit</artifactId>
4242
<scope>test</scope>
4343
</dependency>
44-
<dependency>
45-
<groupId>jakarta.enterprise</groupId>
46-
<artifactId>jakarta.enterprise.cdi-api</artifactId>
47-
<scope>test</scope>
48-
</dependency>
49-
<dependency>
50-
<groupId>org.jboss.weld.se</groupId>
51-
<artifactId>weld-se-core</artifactId>
52-
<scope>test</scope>
53-
</dependency>
5444
<!--ASM Implementations-->
5545
<!--Origin OW2-->
5646
<dependency>
@@ -204,32 +194,18 @@
204194
</configuration>
205195
<executions>
206196
<execution>
207-
<id>test-jpa-jse-without-deadlock</id>
197+
<id>test-jpa-jse</id>
208198
<goals>
209199
<goal>integration-test</goal>
210200
</goals>
211201
<configuration>
212202
<skipTests>${test-skip-jpa-jse}</skipTests>
213203
<reportNameSuffix>test-jpa-jse</reportNameSuffix>
214-
<excludes>
215-
<exclude>CacheDeadLockDetectionTest*</exclude>
216-
</excludes>
217204
<includes>
218205
<include>*.Test*</include>
219206
</includes>
220207
</configuration>
221208
</execution>
222-
<execution>
223-
<id>test-jpa-jse-deadlock</id>
224-
<goals>
225-
<goal>integration-test</goal>
226-
</goals>
227-
<configuration>
228-
<includes>
229-
<include>CacheDeadLockDetectionTest*</include>
230-
</includes>
231-
</configuration>
232-
</execution>
233209
<execution>
234210
<id>verify-integration-tests</id>
235211
<goals>

jpa/eclipselink.jpa.test.jse/src/it/java/org/eclipse/persistence/jpa/test/cachedeadlock/CacheDeadLockDetectionTest.java

Lines changed: 0 additions & 172 deletions
This file was deleted.
Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
3-
Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2018, 2025 Oracle and/or its affiliates. All rights reserved.
44
55
This program and the accompanying materials are made available under the
66
terms of the Eclipse Public License v. 2.0 which is available at
@@ -19,8 +19,8 @@
1919
<persistence-unit name="weaver-pu"
2020
transaction-type="RESOURCE_LOCAL">
2121
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
22-
<exclude-unlisted-classes>false</exclude-unlisted-classes>
2322
<mapping-file>META-INF/fish-orm.xml</mapping-file>
23+
<exclude-unlisted-classes>false</exclude-unlisted-classes>
2424
<properties>
2525
</properties>
2626
</persistence-unit>
@@ -41,15 +41,14 @@
4141

4242
<persistence-unit name="static-small-pu" transaction-type="RESOURCE_LOCAL">
4343
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
44-
<exclude-unlisted-classes>true</exclude-unlisted-classes>
4544
<class>org.eclipse.persistence.jpa.test.basic.model.Employee</class>
45+
<exclude-unlisted-classes>true</exclude-unlisted-classes>
4646
<properties>
4747
</properties>
4848
</persistence-unit>
4949

5050
<persistence-unit name="returninsert-pu" transaction-type="RESOURCE_LOCAL">
5151
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
52-
<exclude-unlisted-classes>true</exclude-unlisted-classes>
5352
<class>org.eclipse.persistence.jpa.returninsert.model.ReturnInsertDetail</class>
5453
<class>org.eclipse.persistence.jpa.returninsert.model.ReturnInsertDetailEmbedded</class>
5554
<class>org.eclipse.persistence.jpa.returninsert.model.ReturnInsertDetailJoined</class>
@@ -58,46 +57,8 @@
5857
<class>org.eclipse.persistence.jpa.returninsert.model.ReturnInsertMasterPK</class>
5958
<class>org.eclipse.persistence.jpa.returninsert.model.ReturnInsertMaster</class>
6059
<class>org.eclipse.persistence.jpa.returninsert.model.ReturnInsertMasterJoined</class>
61-
<properties></properties>
62-
</persistence-unit>
63-
64-
<persistence-unit name="cachedeadlockdetection-pu" transaction-type="RESOURCE_LOCAL">
65-
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
6660
<exclude-unlisted-classes>true</exclude-unlisted-classes>
67-
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionMaster</class>
68-
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionDetail</class>
69-
<properties>
70-
<property name="eclipselink.concurrency.manager.waittime" value="1"/>
71-
<property name="eclipselink.concurrency.manager.maxsleeptime" value="2"/>
72-
<property name="eclipselink.concurrency.manager.maxfrequencytodumptinymessage" value="800"/>
73-
<property name="eclipselink.concurrency.manager.maxfrequencytodumpmassivemessage" value="1000"/>
74-
<property name="eclipselink.concurrency.manager.build.object.complete.waittime" value="5"/>
75-
<property name="eclipselink.concurrency.manager.allow.readlockstacktrace" value="true"/>
76-
<property name="eclipselink.concurrency.manager.allow.concurrencyexception" value="true"/>
77-
<property name="eclipselink.concurrency.manager.allow.interruptedexception" value="true"/>
78-
</properties>
79-
</persistence-unit>
80-
81-
<persistence-unit name="cachedeadlocksemaphore-pu" transaction-type="RESOURCE_LOCAL">
82-
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
83-
<exclude-unlisted-classes>true</exclude-unlisted-classes>
84-
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionMaster</class>
85-
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionDetail</class>
86-
<properties>
87-
<property name="eclipselink.concurrency.manager.waittime" value="1"/>
88-
<property name="eclipselink.concurrency.manager.maxsleeptime" value="2"/>
89-
<property name="eclipselink.concurrency.manager.maxfrequencytodumptinymessage" value="1000"/>
90-
<property name="eclipselink.concurrency.manager.maxfrequencytodumpmassivemessage" value="2000"/>
91-
<property name="eclipselink.concurrency.manager.allow.readlockstacktrace" value="true"/>
92-
<property name="eclipselink.concurrency.manager.allow.concurrencyexception" value="true"/>
93-
<property name="eclipselink.concurrency.manager.allow.interruptedexception" value="true"/>
94-
<property name="eclipselink.concurrency.manager.object.building.semaphore" value="true"/>
95-
<property name="eclipselink.concurrency.manager.object.building.no.threads" value="5"/>
96-
<property name="eclipselink.concurrency.manager.write.lock.manager.semaphore" value="true"/>
97-
<property name="eclipselink.concurrency.manager.write.lock.manager.no.threads" value="6"/>
98-
<property name="eclipselink.concurrency.semaphore.max.time.permit" value="7"/>
99-
<property name="eclipselink.concurrency.semaphore.log.timeout" value="8"/>
100-
</properties>
61+
<properties></properties>
10162
</persistence-unit>
10263

10364
</persistence>

0 commit comments

Comments
 (0)